From d59c4b6fb731e5fddb458106b2e18eed1087c507 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Tue, 27 Mar 2007 14:36:12 +0400 Subject: [PATCH 1/5] [PATCH] Teach gitk to use the user-defined UI font everywhere. Some parts of gitk were not respecting the default GUI font. Most of them were catched and fixed. Signed-off-by: Eygene Ryabinkin Signed-off-by: Paul Mackerras --- gitk | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/gitk b/gitk index db28d745dc..d47d3d8f84 100755 --- a/gitk +++ b/gitk @@ -648,8 +648,10 @@ proc makewindow {} { frame .bright.mode radiobutton .bright.mode.patch -text "Patch" \ -command reselectline -variable cmitmode -value "patch" + .bright.mode.patch configure -font $uifont radiobutton .bright.mode.tree -text "Tree" \ -command reselectline -variable cmitmode -value "tree" + .bright.mode.tree configure -font $uifont grid .bright.mode.patch .bright.mode.tree -sticky ew pack .bright.mode -side top -fill x set cflist .bright.cfiles @@ -922,6 +924,7 @@ proc bindall {event action} { } proc about {} { + global uifont set w .about if {[winfo exists $w]} { raise $w @@ -937,11 +940,14 @@ Copyright Use and redistribute under the terms of the GNU General Public License} \ -justify center -aspect 400 pack $w.m -side top -fill x -padx 20 -pady 20 + $w.m configure -font $uifont button $w.ok -text Close -command "destroy $w" pack $w.ok -side bottom + $w.ok configure -font $uifont } proc keys {} { + global uifont set w .keys if {[winfo exists $w]} { raise $w @@ -990,8 +996,10 @@ f Scroll diff view to next file } \ -justify left -bg white -border 2 -relief sunken pack $w.m -side top -fill both + $w.m configure -font $uifont button $w.ok -text Close -command "destroy $w" pack $w.ok -side bottom + $w.ok configure -font $uifont } # Procedures for manipulating the file list window at the @@ -1457,20 +1465,21 @@ proc vieweditor {top n title} { toplevel $top wm title $top $title label $top.nl -text "Name" -font $uifont - entry $top.name -width 20 -textvariable newviewname($n) + entry $top.name -width 20 -textvariable newviewname($n) -font $uifont grid $top.nl $top.name -sticky w -pady 5 - checkbutton $top.perm -text "Remember this view" -variable newviewperm($n) + checkbutton $top.perm -text "Remember this view" -variable newviewperm($n) \ + -font $uifont grid $top.perm - -pady 5 -sticky w message $top.al -aspect 1000 -font $uifont \ -text "Commits to include (arguments to git rev-list):" grid $top.al - -sticky w -pady 5 entry $top.args -width 50 -textvariable newviewargs($n) \ - -background white + -background white -font $uifont grid $top.args - -sticky ew -padx 5 message $top.l -aspect 1000 -font $uifont \ -text "Enter files and directories to include, one per line:" grid $top.l - -sticky w - text $top.t -width 40 -height 10 -background white + text $top.t -width 40 -height 10 -background white -font $uifont if {[info exists viewfiles($n)]} { foreach f $viewfiles($n) { $top.t insert end $f @@ -1481,8 +1490,10 @@ proc vieweditor {top n title} { } grid $top.t - -sticky ew -padx 5 frame $top.buts - button $top.buts.ok -text "OK" -command [list newviewok $top $n] - button $top.buts.can -text "Cancel" -command [list destroy $top] + button $top.buts.ok -text "OK" -command [list newviewok $top $n] \ + -font $uifont + button $top.buts.can -text "Cancel" -command [list destroy $top] \ + -font $uifont grid $top.buts.ok $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a @@ -5813,6 +5824,7 @@ proc doprefs {} { global maxwidth maxgraphpct diffopts global oldprefs prefstop showneartags global bgcolor fgcolor ctext diffcolors + global uifont set top .gitkprefs set prefstop $top @@ -5826,6 +5838,7 @@ proc doprefs {} { toplevel $top wm title $top "Gitk preferences" label $top.ldisp -text "Commit list display options" + $top.ldisp configure -font $uifont grid $top.ldisp - -sticky w -pady 10 label $top.spacer -text " " label $top.maxwidthl -text "Maximum graph width (lines)" \ @@ -5838,6 +5851,7 @@ proc doprefs {} { grid x $top.maxpctl $top.maxpct -sticky w label $top.ddisp -text "Diff display options" + $top.ddisp configure -font $uifont grid $top.ddisp - -sticky w -pady 10 label $top.diffoptl -text "Options for diff program" \ -font optionfont @@ -5850,6 +5864,7 @@ proc doprefs {} { grid x $top.ntag -sticky w label $top.cdisp -text "Colors: press to choose" + $top.cdisp configure -font $uifont grid $top.cdisp - -sticky w -pady 10 label $top.bg -padx 40 -relief sunk -background $bgcolor button $top.bgbut -text "Background" -font optionfont \ @@ -5878,7 +5893,9 @@ proc doprefs {} { frame $top.buts button $top.buts.ok -text "OK" -command prefsok + $top.buts.ok configure -font $uifont button $top.buts.can -text "Cancel" -command prefscan + $top.buts.can configure -font $uifont grid $top.buts.ok $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a From 3a950e9a9cfc2eb4e30cf6e8658dab25196d746e Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Tue, 27 Mar 2007 14:36:59 +0400 Subject: [PATCH 2/5] [PATCH] Improve look-and-feel of the gitk tool. Made the default buttons on the dialog active and focused upon the dialog appearence. Bound 'Escape' and 'Return' keys to the dialog dismissal where it was appropriate: mainly for dialogs with only one button and no editable fields. Unified the look of the "About gitk" and "Key bindings" dialogs. Signed-off-by: Eygene Ryabinkin Signed-off-by: Paul Mackerras --- gitk | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/gitk b/gitk index d47d3d8f84..b1c65d7680 100755 --- a/gitk +++ b/gitk @@ -938,12 +938,15 @@ Gitk - a commit viewer for git Copyright © 2005-2006 Paul Mackerras Use and redistribute under the terms of the GNU General Public License} \ - -justify center -aspect 400 - pack $w.m -side top -fill x -padx 20 -pady 20 + -justify center -aspect 400 -border 2 -bg white -relief groove + pack $w.m -side top -fill x -padx 2 -pady 2 $w.m configure -font $uifont - button $w.ok -text Close -command "destroy $w" + button $w.ok -text Close -command "destroy $w" -default active pack $w.ok -side bottom $w.ok configure -font $uifont + bind $w "focus $w.ok" + bind $w "destroy $w" + bind $w "destroy $w" } proc keys {} { @@ -994,12 +997,15 @@ f Scroll diff view to next file Decrease font size Update } \ - -justify left -bg white -border 2 -relief sunken - pack $w.m -side top -fill both + -justify left -bg white -border 2 -relief groove + pack $w.m -side top -fill both -padx 2 -pady 2 $w.m configure -font $uifont - button $w.ok -text Close -command "destroy $w" + button $w.ok -text Close -command "destroy $w" -default active pack $w.ok -side bottom $w.ok configure -font $uifont + bind $w "focus $w.ok" + bind $w "destroy $w" + bind $w "destroy $w" } # Procedures for manipulating the file list window at the @@ -5892,14 +5898,15 @@ proc doprefs {} { grid x $top.hunksepbut $top.hunksep -sticky w frame $top.buts - button $top.buts.ok -text "OK" -command prefsok + button $top.buts.ok -text "OK" -command prefsok -default active $top.buts.ok configure -font $uifont - button $top.buts.can -text "Cancel" -command prefscan + button $top.buts.can -text "Cancel" -command prefscan -default normal $top.buts.can configure -font $uifont grid $top.buts.ok $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - - -pady 10 -sticky ew + bind $top "focus $top.buts.ok" } proc choosecolor {v vi w x cmd} { From 1bb88be99e4fdedcd5cc5292c11b566a00028deb Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Sat, 14 Apr 2007 17:26:20 -0400 Subject: [PATCH 3/5] git-blame: Fix overrun in fake_working_tree_commit() git-blame would overflow commit->buffer when annotating files with long paths. Signed-off-by: Michael Spang Signed-off-by: Junio C Hamano --- builtin-blame.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-blame.c b/builtin-blame.c index 60ec5354f1..bc86bda6c4 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -2041,7 +2041,7 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con commit->buffer = xmalloc(400); ident = fmt_ident("Not Committed Yet", "not.committed.yet", NULL, 0); - sprintf(commit->buffer, + snprintf(commit->buffer, 400, "tree 0000000000000000000000000000000000000000\n" "parent %s\n" "author %s\n" From 61d6ed139ff572937c8ff342cfa16e40d2f9011e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 10 Apr 2007 01:01:44 +0200 Subject: [PATCH 4/5] sscanf/strtoul: parse integers robustly * builtin-grep.c (strtoul_ui): Move function definition from here, to... * git-compat-util.h (strtoul_ui): ...here, with an added "base" parameter. * builtin-grep.c (cmd_grep): Update use of strtoul_ui to include base, "10". * builtin-update-index.c (read_index_info): Diagnose an invalid mode integer that is out of range or merely larger than INT_MAX. (cmd_update_index): Use strtoul_ui, not sscanf. * convert-objects.c (write_subdirectory): Likewise. Signed-off-by: Jim Meyering Signed-off-by: Junio C Hamano --- builtin-grep.c | 15 +-------------- builtin-update-index.c | 10 +++++++--- convert-objects.c | 2 +- git-compat-util.h | 13 +++++++++++++ 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/builtin-grep.c b/builtin-grep.c index 981f3d4d8e..e13cb31f2b 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -434,19 +434,6 @@ static const char emsg_missing_context_len[] = static const char emsg_missing_argument[] = "option requires an argument -%s"; -static int strtoul_ui(char const *s, unsigned int *result) -{ - unsigned long ul; - char *p; - - errno = 0; - ul = strtoul(s, &p, 10); - if (errno || *p || p == s || (unsigned int) ul != ul) - return -1; - *result = ul; - return 0; -} - int cmd_grep(int argc, const char **argv, const char *prefix) { int hit = 0; @@ -569,7 +556,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) scan = arg + 1; break; } - if (strtoul_ui(scan, &num)) + if (strtoul_ui(scan, 10, &num)) die(emsg_invalid_context_len, scan); switch (arg[1]) { case 'A': diff --git a/builtin-update-index.c b/builtin-update-index.c index 71cef633c0..6ed61ebc57 100644 --- a/builtin-update-index.c +++ b/builtin-update-index.c @@ -227,6 +227,7 @@ static void read_index_info(int line_termination) char *path_name; unsigned char sha1[20]; unsigned int mode; + unsigned long ul; int stage; /* This reads lines formatted in one of three formats: @@ -249,9 +250,12 @@ static void read_index_info(int line_termination) if (buf.eof) break; - mode = strtoul(buf.buf, &ptr, 8); - if (ptr == buf.buf || *ptr != ' ') + errno = 0; + ul = strtoul(buf.buf, &ptr, 8); + if (ptr == buf.buf || *ptr != ' ' + || errno || (unsigned int) ul != ul) goto bad_line; + mode = ul; tab = strchr(ptr, '\t'); if (!tab || tab - ptr < 41) @@ -547,7 +551,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) if (i+3 >= argc) die("git-update-index: --cacheinfo "); - if ((sscanf(argv[i+1], "%o", &mode) != 1) || + if ((strtoul_ui(argv[i+1], 8, &mode) != 1) || get_sha1_hex(argv[i+2], sha1) || add_cacheinfo(mode, sha1, argv[i+3], 0)) die("git-update-index: --cacheinfo" diff --git a/convert-objects.c b/convert-objects.c index 4809f9199f..cf03bcfe5a 100644 --- a/convert-objects.c +++ b/convert-objects.c @@ -88,7 +88,7 @@ static int write_subdirectory(void *buffer, unsigned long size, const char *base unsigned int mode; char *slash, *origpath; - if (!path || sscanf(buffer, "%o", &mode) != 1) + if (!path || strtoul_ui(buffer, 8, &mode) != 1) die("bad tree conversion"); mode = convert_mode(mode); path++; diff --git a/git-compat-util.h b/git-compat-util.h index 139fc19108..5f6a281b78 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -301,4 +301,17 @@ static inline int prefixcmp(const char *str, const char *prefix) return strncmp(str, prefix, strlen(prefix)); } +static inline int strtoul_ui(char const *s, int base, unsigned int *result) +{ + unsigned long ul; + char *p; + + errno = 0; + ul = strtoul(s, &p, base); + if (errno || *p || p == s || (unsigned int) ul != ul) + return -1; + *result = ul; + return 0; +} + #endif From 5f2e1df5c9fa7856e5d7dda7d6c618ed08822b82 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Mon, 16 Apr 2007 00:36:06 +0200 Subject: [PATCH 5/5] Document -g (--walk-reflogs) option of git-log Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- Documentation/git-log.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index 030edaf305..49bb539dea 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -46,6 +46,11 @@ include::pretty-formats.txt[] -p:: Show the change the commit introduces in a patch form. +-g, \--walk-reflogs:: + Show commits as they were recorded in the reflog. The log contains + a record about how the tip of a reference was changed. + See also gitlink:git-reflog[1]. + ...:: Show only commits that affect the specified paths.