Skip to content

Commit 6e8d538

Browse files
committed
Merge branch 'master' of https://github.com/j6t/git-gui
* 'master' of https://github.com/j6t/git-gui: git-gui: grey out comment lines in commit message git-gui: wire up "git-gui--askyesno" with Meson git-gui: massage "git-gui--askyesno" with "generate-script.sh" git-gui: prefer shell at "/bin/sh" with Meson git-gui: fix use of GIT_CEILING_DIRECTORIES git-gui: shift tabstops to account for the first column of patch text
2 parents b70a02d + bb52cda commit 6e8d538

File tree

8 files changed

+58
-21
lines changed

8 files changed

+58
-21
lines changed

git-gui/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ GIT-GUI-BUILD-OPTIONS
55
GIT-VERSION-FILE
66
git-gui
77
git-gui--askpass
8+
git-gui--askyesno
89
lib/tclIndex

git-gui/GIT-VERSION-GEN

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@ DEF_VER=0.21.GITGUI
55
LF='
66
'
77

8-
if test "$#" -ne 2
8+
if test "$#" -lt 2
99
then
10-
echo >&2 "usage: $0 <SOURCE_DIR> <OUTPUT>"
10+
echo >&2 "usage: $0 <SOURCE_DIR> <OUTPUT> [<PARENT_PROJECT_DIR>]"
1111
exit 1
1212
fi
1313

1414
SOURCE_DIR="$1"
1515
OUTPUT="$2"
16+
PARENT_PROJECT_DIR="$3"
1617

1718
# Protect us from reading Git version information outside of the Git directory
1819
# in case it is not a repository itself, but embedded in an unrelated
19-
# repository.
20-
GIT_CEILING_DIRECTORIES="$SOURCE_DIR/.."
20+
# repository. The PARENT_PROJECT_DIR variable can be used to override this, for
21+
# example when git-gui is included as a subproject.
22+
if test -n "$PARENT_PROJECT_DIR"
23+
then
24+
GIT_CEILING_DIRECTORIES="$PARENT_PROJECT_DIR/.."
25+
else
26+
GIT_CEILING_DIRECTORIES="$SOURCE_DIR/.."
27+
fi
28+
2129
export GIT_CEILING_DIRECTORIES
2230

2331
tree_search ()

git-gui/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ all::
99
#
1010

1111
GIT-VERSION-FILE: FORCE
12-
@$(SHELL_PATH) ./GIT-VERSION-GEN . $@
12+
@$(SHELL_PATH) ./GIT-VERSION-GEN . $@ "$(PARENT_PROJECT_DIR)"
1313

1414
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
1515
uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
@@ -177,10 +177,13 @@ GIT-GUI-BUILD-OPTIONS: FORCE
177177
git-gui--askpass: git-gui--askpass.sh GIT-GUI-BUILD-OPTIONS generate-script.sh
178178
$(QUIET_GEN)$(SHELL_PATH) generate-script.sh $@ $< ./GIT-GUI-BUILD-OPTIONS
179179

180+
git-gui--askyesno: git-gui--askyesno.sh GIT-GUI-BUILD-OPTIONS generate-script.sh
181+
$(QUIET_GEN)$(SHELL_PATH) generate-script.sh $@ $< ./GIT-GUI-BUILD-OPTIONS
182+
180183
ifdef GITGUI_WINDOWS_WRAPPER
181184
all:: git-gui
182185
endif
183-
all:: $(GITGUI_MAIN) git-gui--askpass lib/tclIndex $(ALL_MSGFILES)
186+
all:: $(GITGUI_MAIN) git-gui--askpass git-gui--askyesno lib/tclIndex $(ALL_MSGFILES)
184187

185188
install: all
186189
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
@@ -221,7 +224,7 @@ dist-version: GIT-VERSION-FILE
221224
@sed 's|^GITGUI_VERSION=||' <GIT-VERSION-FILE >$(TARDIR)/version
222225

223226
clean::
224-
$(RM_RF) $(GITGUI_MAIN) git-gui--askpass lib/tclIndex po/*.msg $(PO_TEMPLATE)
227+
$(RM_RF) $(GITGUI_MAIN) git-gui--askpass git-gui--askyesno lib/tclIndex po/*.msg $(PO_TEMPLATE)
225228
$(RM_RF) GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
226229
ifdef GITGUI_WINDOWS_WRAPPER
227230
$(RM_RF) git-gui

git-gui/git-gui.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3900,6 +3900,24 @@ if {[winfo exists $ui_comm]} {
39003900

39013901
backup_commit_buffer
39023902

3903+
# Grey out comment lines (which are stripped from the final commit message by
3904+
# wash_commit_message).
3905+
$ui_comm tag configure commit_comment -foreground gray
3906+
proc dim_commit_comment_lines {} {
3907+
global ui_comm comment_string
3908+
$ui_comm tag remove commit_comment 1.0 end
3909+
set text [$ui_comm get 1.0 end]
3910+
# See also cmt_rx in wash_commit_message
3911+
set cmt_rx [strcat {^} [regsub -all {\W} $comment_string {\\&}]]
3912+
set ranges [regexp -all -indices -inline -line -- $cmt_rx $text]
3913+
foreach pair $ranges {
3914+
set idx "1.0 + [lindex $pair 0] chars"
3915+
$ui_comm tag add commit_comment $idx "$idx lineend + 1 char"
3916+
}
3917+
}
3918+
dim_commit_comment_lines
3919+
bind $ui_comm <<Modified>> { after idle dim_commit_comment_lines }
3920+
39033921
# -- If the user has aspell available we can drive it
39043922
# in pipe mode to spellcheck the commit message.
39053923
#

git-gui/lib/diff.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ proc read_diff {fd conflict_size cont_info} {
385385
#
386386
if {[string match {@@@ *} $line]} {
387387
set is_3way_diff 1
388+
apply_tab_size 2
389+
} elseif {[string match {@@ *} $line]} {
388390
apply_tab_size 1
389391
}
390392

git-gui/meson.build

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ project('git-gui',
44

55
fs = import('fs')
66

7-
shell = find_program('sh')
7+
shell = find_program('/bin/sh', 'sh')
88
tclsh = find_program('tclsh')
99
wish = find_program('wish')
1010

@@ -34,6 +34,7 @@ version_file = custom_target(
3434
'@INPUT@',
3535
meson.current_source_dir(),
3636
'@OUTPUT@',
37+
get_option('parent_project_dir'),
3738
],
3839
build_always_stale: true,
3940
)
@@ -53,19 +54,21 @@ if target_machine.system() == 'windows'
5354
)
5455
endif
5556

56-
custom_target(
57-
output: 'git-gui--askpass',
58-
input: 'git-gui--askpass.sh',
59-
command: [
60-
shell,
61-
meson.current_source_dir() / 'generate-script.sh',
62-
'@OUTPUT@',
63-
'@INPUT@',
64-
meson.current_build_dir() / 'GIT-GUI-BUILD-OPTIONS',
65-
],
66-
install: true,
67-
install_dir: get_option('libexecdir') / 'git-core',
68-
)
57+
foreach script : [ 'git-gui--askpass', 'git-gui--askyesno' ]
58+
custom_target(
59+
output: script,
60+
input: script + '.sh',
61+
command: [
62+
shell,
63+
meson.current_source_dir() / 'generate-script.sh',
64+
'@OUTPUT@',
65+
'@INPUT@',
66+
meson.current_build_dir() / 'GIT-GUI-BUILD-OPTIONS',
67+
],
68+
install: true,
69+
install_dir: get_option('libexecdir') / 'git-core',
70+
)
71+
endforeach
6972

7073
custom_target(
7174
input: 'git-gui.sh',

git-gui/meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
option('parent_project_dir', type: 'string', value: '',
2+
description: 'The directory of the parent project. This is used so that the version can be determined even in case git-gui is included as a subtree.')

0 commit comments

Comments
 (0)