git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Using "git log" to find the files patched at the same time as a named  file
@ 2010-02-03 20:38 Zack Brown
  2010-02-03 20:52 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Zack Brown @ 2010-02-03 20:38 UTC (permalink / raw)
  To: git

Hi folks,

If I have a filename I'm interested in, and I want to find other files
that have been modified in the same commits that modified the file I'm
interested in, how could I do that with git?

If I give the command
$ git log --name-only
then the bottom of each log entry will list all the files that were
modified by that commit. That's basically what I want, except that the
command will list all log entries, not just the ones that modified the
file I'm interested in.

If I give the command
$ git log --name-only fs/fuse/file.c
then the bottom of each log entry only lists fs/fuse/file.c, even if
the very same commit showed up in the output from the previous command
with multiple files in addition to that one. In other words, the "git
log --name-only fs/fuse/file.c" command will only list fs/fuse/file.c
as being changed, in commits that I know changed more than just that
one file.

Is there a git command that will run in roughly the same amount of
time as the ones given above (i.e. with only a single invocation of
git), but that will only output the commits that affected the file I'm
interested in, and that will also list any other files changed in
those same commits?

Many thanks,
Zack

-- 
Zack Brown

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using "git log" to find the files patched at the same time as a named  file
  2010-02-03 20:38 Using "git log" to find the files patched at the same time as a named file Zack Brown
@ 2010-02-03 20:52 ` Junio C Hamano
  2010-02-03 21:14   ` Zack Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2010-02-03 20:52 UTC (permalink / raw)
  To: Zack Brown; +Cc: git

Zack Brown <zacharyb@gmail.com> writes:

> If I have a filename I'm interested in, and I want to find other files
> that have been modified in the same commits that modified the file I'm
> interested in, how could I do that with git?

Like this?

$ git log --full-diff --name-status v1.6.0..master -- Makefile

to ask "Which files have changed in the commit that touch Makefile since
v1.6.0 up to the tip of the master?"

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using "git log" to find the files patched at the same time as a  named file
  2010-02-03 20:52 ` Junio C Hamano
@ 2010-02-03 21:14   ` Zack Brown
  2010-02-03 21:36     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Zack Brown @ 2010-02-03 21:14 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, Feb 3, 2010 at 3:52 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Zack Brown <zacharyb@gmail.com> writes:
>
>> If I have a filename I'm interested in, and I want to find other files
>> that have been modified in the same commits that modified the file I'm
>> interested in, how could I do that with git?
>
> Like this?
>
> $ git log --full-diff --name-status v1.6.0..master -- Makefile

Yes! Thank you!

I went back to the man page to see why I didn't find that before.
Here's the text for the --full-diff option:

   "Without this flag, "git log -p <path>..." shows commits that touch
   the specified paths, and diffs about the same specified paths. With
   this, the full diff is shown for commits that touch the specified
   paths; this means that "<path>..." limits only commits, and doesn’t
   limit diff for those commits."

That's all the text that deals with --full-diff in the git log
manpage. I'm not sure what it's trying to say - it seems really hard
to understand. What about something like this:

"Without this flag, "git log -p <path>..." shows commits that touch
the specified paths, but it only includes the diffs from those commits
that affected those specified paths, regardless of whether other paths
were changed in those same commits. With "git log --full-diff -p
<path>...", git still only reports commits that touch the specified
path, but now it also includes the diffs that affected any other paths
changed in those same commits."

Would that be an improvement?

Be well,
Zack

>
> to ask "Which files have changed in the commit that touch Makefile since
> v1.6.0 up to the tip of the master?"
>



-- 
Zack Brown

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using "git log" to find the files patched at the same time as a  named file
  2010-02-03 21:14   ` Zack Brown
@ 2010-02-03 21:36     ` Junio C Hamano
  2010-02-03 21:52       ` Zack Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2010-02-03 21:36 UTC (permalink / raw)
  To: Zack Brown; +Cc: git

Zack Brown <zacharyb@gmail.com> writes:

> ... What about something like this:
>
> "Without this flag, "git log -p <path>..." shows commits that touch
> the specified paths, but it only includes the diffs from those commits

I would say "s/but/and/", because it is more natural that you get the
"limited" view after you explicitly stated that you are "only interested
in these things" by giving pathspecs.

> that affected those specified paths, regardless of whether other paths
> were changed in those same commits. With "git log --full-diff -p
> <path>...", git still only reports commits that touch the specified
> path, but now it also includes the diffs that affected any other paths
> changed in those same commits."

And "but" on the second line from the bottom makes sense---by giving the
option, you are telling it to work differently.

> Would that be an improvement?

Surely.  I would suspect that people would go even further.  "-p" is not
very special (notice I used --name-status in my example).

Also I think the description should start with what it _does_, not with
what happens without it.

So how about this?

diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 0e39bb6..5dd1c0c 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -49,11 +49,14 @@ include::diff-options.txt[]
 	commit was reached.
 
 --full-diff::
-	Without this flag, "git log -p <path>..." shows commits that
-	touch the specified paths, and diffs about the same specified
-	paths.  With this, the full diff is shown for commits that touch
-	the specified paths; this means that "<path>..." limits only
-	commits, and doesn't limit diff for those commits.
+	Show all changes, even outside the given pathspecs.
++
+Pathspecs <path>... given to "git log [<options>] <path>..."  limit the
+output to the commits that touch the specified paths.  When options to
+show changes introduced by these commits (e.g. "-p", "--name-only") are
+given, the output of the changes are also limited to the specified paths.
+This option lifts the latter limit and tells "git log" to include all
+changes, even the ones outside of the given pathspecs.
 
 --follow::
 	Continue listing the history of a file beyond renames.

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Using "git log" to find the files patched at the same time as a  named file
  2010-02-03 21:36     ` Junio C Hamano
@ 2010-02-03 21:52       ` Zack Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Zack Brown @ 2010-02-03 21:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

That looks much clearer. But I would change the final sentence to,
"This option lifts that limit and tells "git log" to include changes
from all paths that were affected by the outputted commits, not just
the changes from the paths specified on the command line."

Be well,
Zack

On Wed, Feb 3, 2010 at 4:36 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Zack Brown <zacharyb@gmail.com> writes:
>
>> ... What about something like this:
>>
>> "Without this flag, "git log -p <path>..." shows commits that touch
>> the specified paths, but it only includes the diffs from those commits
>
> I would say "s/but/and/", because it is more natural that you get the
> "limited" view after you explicitly stated that you are "only interested
> in these things" by giving pathspecs.
>
>> that affected those specified paths, regardless of whether other paths
>> were changed in those same commits. With "git log --full-diff -p
>> <path>...", git still only reports commits that touch the specified
>> path, but now it also includes the diffs that affected any other paths
>> changed in those same commits."
>
> And "but" on the second line from the bottom makes sense---by giving the
> option, you are telling it to work differently.
>
>> Would that be an improvement?
>
> Surely.  I would suspect that people would go even further.  "-p" is not
> very special (notice I used --name-status in my example).
>
> Also I think the description should start with what it _does_, not with
> what happens without it.
>
> So how about this?
>
> diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
> index 0e39bb6..5dd1c0c 100644
> --- a/Documentation/git-log.txt
> +++ b/Documentation/git-log.txt
> @@ -49,11 +49,14 @@ include::diff-options.txt[]
>        commit was reached.
>
>  --full-diff::
> -       Without this flag, "git log -p <path>..." shows commits that
> -       touch the specified paths, and diffs about the same specified
> -       paths.  With this, the full diff is shown for commits that touch
> -       the specified paths; this means that "<path>..." limits only
> -       commits, and doesn't limit diff for those commits.
> +       Show all changes, even outside the given pathspecs.
> ++
> +Pathspecs <path>... given to "git log [<options>] <path>..."  limit the
> +output to the commits that touch the specified paths.  When options to
> +show changes introduced by these commits (e.g. "-p", "--name-only") are
> +given, the output of the changes are also limited to the specified paths.
> +This option lifts the latter limit and tells "git log" to include all
> +changes, even the ones outside of the given pathspecs.
>
>  --follow::
>        Continue listing the history of a file beyond renames.
>
>
>



-- 
Zack Brown

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-03 21:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-03 20:38 Using "git log" to find the files patched at the same time as a named file Zack Brown
2010-02-03 20:52 ` Junio C Hamano
2010-02-03 21:14   ` Zack Brown
2010-02-03 21:36     ` Junio C Hamano
2010-02-03 21:52       ` Zack Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).