# [PATCH v2] gitk: Show patch for initial commit

4 messages from 2011-10-01 to 2011-10-03. Participants: Marcus Karlsson, Zbigniew Jędrzejewski-Szmek, Junio C Hamano.
Thread: https://gitlist.dev/t/28547

## Marcus Karlsson, 2011-10-01 19:05

Subject: [PATCH v2] gitk: Show patch for initial commit
Message-ID: <20111001190554.GA5854@kennedy.acc.umu.se>
URL: https://gitlist.dev/e/20111001190554.GA5854%40kennedy.acc.umu.se

```
Make gitk show the patch for the initial commit by default.
Override with log.showroot.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>
---
 gitk-git/gitk |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 4cde0c4..40ea73f 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -7402,7 +7402,7 @@ proc addtocflist {ids} {
 }
 
 proc diffcmd {ids flags} {
-    global nullid nullid2
+    global log_showroot nullid nullid2
 
     set i [lsearch -exact $ids $nullid]
     set j [lsearch -exact $ids $nullid2]
@@ -7436,7 +7436,11 @@ proc diffcmd {ids flags} {
 	    lappend cmd HEAD
 	}
     } else {
-	set cmd [concat | git diff-tree -r $flags $ids]
+	set cmd [concat | git diff-tree -r]
+	if {$log_showroot eq true} {
+	    set cmd [concat $cmd --root]
+	}
+	set cmd [concat $cmd $flags $ids]
     }
     return $cmd
 }
@@ -11403,6 +11407,11 @@ catch {
     }
 }
 
+set log_showroot true
+catch {
+    set log_showroot [exec git config --get log.showroot]
+}
+
 if {[tk windowingsystem] eq "aqua"} {
     set mainfont {{Lucida Grande} 9}
     set textfont {Monaco 9}
-- 
1.7.7

```

## Zbigniew Jędrzejewski-Szmek, 2011-10-01 21:03

Subject: Re: [PATCH v2] gitk: Show patch for initial commit
Message-ID: <4E878016.703@in.waw.pl>
URL: https://gitlist.dev/e/4E878016.703%40in.waw.pl
In-Reply-To: <20111001190554.GA5854@kennedy.acc.umu.se>

```
[cc: Paul Mackerras]

Hi,
I think that the historical explanation that Junio gave could
be used as a basis for a commit message:

  In early days, all projects managed by git (except for git itself) had the
  product of a fairly mature development history in their first commit, and
  it was deemed unnecessary clutter to show additions of these thousands of
  paths as a patch.

  "git log" learned to show the patch for the initial commit without requiring
  --root command line option at 0f03ca9 (config option log.showroot to show
  the diff of root commits, 2006-11-23).

  Teach gitk to respect log.showroot.

Also the gitk should be mentioned in the man-page for git-config log.showroot.
The current description of this option seems suboptimal because it explains
how it used to be, which is not really relevant:
  log.showroot
    If true, the initial commit will be shown as a big creation event. This is
    equivalent to a diff against an empty tree. Tools like git-log(1) or git-
    whatchanged(1), which normally hide the root commit will now show it. True by
    default.
This could be changed to:
    If true (the default), the root commit will be shown as a big creation
    event --- a diff against an empty tree. This diff can be very large for
    a project which was imported into git after some development history.
    If log.showroot is false tools like git-log(1), git-whatchanged(1), or
    gitk(1) will not display the added files.
    
Zbyszek

On 10/01/2011 09:05 PM, Marcus Karlsson wrote:
> Make gitk show the patch for the initial commit by default.
> Override with log.showroot.
> 
> Signed-off-by: Marcus Karlsson<mk@acc.umu.se>
> ---
>   gitk-git/gitk |   13 +++++++++++--
>   1 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index 4cde0c4..40ea73f 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -7402,7 +7402,7 @@ proc addtocflist {ids} {
>   }
> 
>   proc diffcmd {ids flags} {
> -    global nullid nullid2
> +    global log_showroot nullid nullid2
> 
>       set i [lsearch -exact $ids $nullid]
>       set j [lsearch -exact $ids $nullid2]
> @@ -7436,7 +7436,11 @@ proc diffcmd {ids flags} {
>   	    lappend cmd HEAD
>   	}
>       } else {
> -	set cmd [concat | git diff-tree -r $flags $ids]
> +	set cmd [concat | git diff-tree -r]
> +	if {$log_showroot eq true} {
> +	    set cmd [concat $cmd --root]
> +	}
> +	set cmd [concat $cmd $flags $ids]
>       }
>       return $cmd
>   }
> @@ -11403,6 +11407,11 @@ catch {
>       }
>   }
> 
> +set log_showroot true
> +catch {
> +    set log_showroot [exec git config --get log.showroot]
> +}
> +
>   if {[tk windowingsystem] eq "aqua"} {
>       set mainfont {{Lucida Grande} 9}
>       set textfont {Monaco 9}

```

## Marcus Karlsson, 2011-10-03 06:33

Subject: Re: [PATCH v2] gitk: Show patch for initial commit
Message-ID: <20111003063359.GA11391@kennedy.acc.umu.se>
URL: https://gitlist.dev/e/20111003063359.GA11391%40kennedy.acc.umu.se
In-Reply-To: <4E878016.703@in.waw.pl>

```
On Sat, Oct 01, 2011 at 11:03:18PM +0200, Zbigniew J??drzejewski-Szmek wrote:
> [cc: Paul Mackerras]
> 
> Hi,
> I think that the historical explanation that Junio gave could
> be used as a basis for a commit message:
> 
>   In early days, all projects managed by git (except for git itself) had the
>   product of a fairly mature development history in their first commit, and
>   it was deemed unnecessary clutter to show additions of these thousands of
>   paths as a patch.
> 
>   "git log" learned to show the patch for the initial commit without requiring
>   --root command line option at 0f03ca9 (config option log.showroot to show
>   the diff of root commits, 2006-11-23).
> 
>   Teach gitk to respect log.showroot.

Absolutely, that would be a much better commit message. I'll wait and
see if there are more comments and then resubmit.

> Also the gitk should be mentioned in the man-page for git-config log.showroot.
> The current description of this option seems suboptimal because it explains
> how it used to be, which is not really relevant:
>   log.showroot
>     If true, the initial commit will be shown as a big creation event. This is
>     equivalent to a diff against an empty tree. Tools like git-log(1) or git-
>     whatchanged(1), which normally hide the root commit will now show it. True by
>     default.
> This could be changed to:
>     If true (the default), the root commit will be shown as a big creation
>     event --- a diff against an empty tree. This diff can be very large for
>     a project which was imported into git after some development history.
>     If log.showroot is false tools like git-log(1), git-whatchanged(1), or
>     gitk(1) will not display the added files.

I agree, but that feels like something that could be made into a
separate patch. Or should I include that too?

	Marcus

```

## Junio C Hamano, 2011-10-03 17:44

Subject: Re: [PATCH v2] gitk: Show patch for initial commit
Message-ID: <7v7h4mgeb7.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v7h4mgeb7.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20111003063359.GA11391@kennedy.acc.umu.se>

```
Marcus Karlsson <mk@acc.umu.se> writes:

>> Also the gitk should be mentioned in the man-page for git-config log.showroot.
>> The current description of this option seems suboptimal because it explains
>> how it used to be, which is not really relevant:
>>   log.showroot
>>     If true, the initial commit will be shown as a big creation event. This is
>>     equivalent to a diff against an empty tree. Tools like git-log(1) or git-
>>     whatchanged(1), which normally hide the root commit will now show it. True by
>>     default.
>> This could be changed to:
>>     If true (the default), the root commit will be shown as a big creation
>>     event --- a diff against an empty tree. This diff can be very large for
>>     a project which was imported into git after some development history.
>>     If log.showroot is false tools like git-log(1), git-whatchanged(1), or
>>     gitk(1) will not display the added files.
>
> I agree, but that feels like something that could be made into a
> separate patch. Or should I include that too?

Please make it a separate patch. A patch to Documentation/config.txt
should go to git.git project, but gitk patch (whose "diff --git" line
should read "diff --git a/gitk b/gitk") should go first to gitk.git
project and then merged to my tree.

```
