Skip to content

Commit 6d5e6ff

Browse files
author
Junio C Hamano
committed
Merge branch 'master' into next
* master: Merge part of kh/svnimport branch into master contrib/git-svn: correct commit example in manpage contrib/git-svn: tell the user to not modify git-svn-HEAD directly gitview: Remove trailing white space gitview: Fix the encoding related bug git-format-patch: Always add a blank line between headers and body. combine-diff: Honour -z option correctly. combine-diff: Honour --full-index.
2 parents bfea9fc + f3a4ec4 commit 6d5e6ff

File tree

4 files changed

+48
-26
lines changed

4 files changed

+48
-26
lines changed

combine-diff.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ static void reuse_combine_diff(struct sline *sline, unsigned long cnt,
621621
}
622622

623623
static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
624-
int dense, const char *header)
624+
int dense, const char *header,
625+
struct diff_options *opt)
625626
{
626627
unsigned long size, cnt, lno;
627628
char *result, *cp, *ep;
@@ -631,6 +632,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
631632
char ourtmp_buf[TMPPATHLEN];
632633
char *ourtmp = ourtmp_buf;
633634
int working_tree_file = !memcmp(elem->sha1, null_sha1, 20);
635+
int abbrev = opt->full_index ? 40 : DEFAULT_ABBREV;
634636

635637
/* Read the result of merge first */
636638
if (!working_tree_file) {
@@ -724,7 +726,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
724726

725727
if (header) {
726728
shown_header++;
727-
puts(header);
729+
printf("%s%c", header, opt->line_termination);
728730
}
729731
printf("diff --%s ", dense ? "cc" : "combined");
730732
if (quote_c_style(elem->path, NULL, NULL, 0))
@@ -735,10 +737,10 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
735737
printf("index ");
736738
for (i = 0; i < num_parent; i++) {
737739
abb = find_unique_abbrev(elem->parent[i].sha1,
738-
DEFAULT_ABBREV);
740+
abbrev);
739741
printf("%s%s", i ? "," : "", abb);
740742
}
741-
abb = find_unique_abbrev(elem->sha1, DEFAULT_ABBREV);
743+
abb = find_unique_abbrev(elem->sha1, abbrev);
742744
printf("..%s\n", abb);
743745

744746
if (mode_differs) {
@@ -797,7 +799,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, const cha
797799
inter_name_termination = 0;
798800

799801
if (header)
800-
puts(header);
802+
printf("%s%c", header, line_termination);
801803

802804
for (i = 0; i < num_parent; i++) {
803805
if (p->parent[i].mode)
@@ -862,7 +864,7 @@ int show_combined_diff(struct combine_diff_path *p,
862864

863865
default:
864866
case DIFF_FORMAT_PATCH:
865-
return show_patch_diff(p, num_parent, dense, header);
867+
return show_patch_diff(p, num_parent, dense, header, opt);
866868
}
867869
}
868870

contrib/git-svn/git-svn.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ fetch::
4343
Fetch unfetched revisions from the SVN_URL we are tracking.
4444
refs/heads/git-svn-HEAD will be updated to the latest revision.
4545

46+
Note: You should never attempt to modify the git-svn-HEAD branch
47+
outside of git-svn. Instead, create a branch from git-svn-HEAD
48+
and work on that branch. Use the 'commit' command (see below)
49+
to write git commits back to git-svn-HEAD.
50+
4651
commit::
4752
Commit specified commit or tree objects to SVN. This relies on
4853
your imported fetch data being up-to-date. This makes
@@ -154,7 +159,7 @@ Tracking and contributing to an Subversion managed-project:
154159
# Commit only the git commits you want to SVN::
155160
git-svn commit <tree-ish> [<tree-ish_2> ...]
156161
# Commit all the git commits from my-branch that don't exist in SVN::
157-
git commit git-svn-HEAD..my-branch
162+
git-svn commit git-svn-HEAD..my-branch
158163
# Something is committed to SVN, pull the latest into your branch::
159164
git-svn fetch && git pull . git-svn-HEAD
160165
# Append svn:ignore settings to the default git exclude file:
@@ -179,7 +184,9 @@ SVN repositories via one git repository. Simply set the GIT_SVN_ID
179184
environment variable to a name other other than "git-svn" (the default)
180185
and git-svn will ignore the contents of the $GIT_DIR/git-svn directory
181186
and instead do all of its work in $GIT_DIR/$GIT_SVN_ID for that
182-
invocation.
187+
invocation. The interface branch will be $GIT_SVN_ID-HEAD, instead of
188+
git-svn-HEAD. Any $GIT_SVN_ID-HEAD branch should never be modified
189+
by the user outside of git-svn commands.
183190

184191
ADDITIONAL FETCH ARGUMENTS
185192
--------------------------

contrib/gitview/gitview

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class CellRendererGraph(gtk.GenericCellRenderer):
162162
for item in names:
163163
names_len += len(item)
164164

165-
width = box_size * (cols + 1 ) + names_len
165+
width = box_size * (cols + 1 ) + names_len
166166
height = box_size
167167

168168
# FIXME I have no idea how to use cell_area properly
@@ -261,11 +261,11 @@ class Commit:
261261
children_sha1 = {}
262262

263263
def __init__(self, commit_lines):
264-
self.message = ""
264+
self.message = ""
265265
self.author = ""
266-
self.date = ""
267-
self.committer = ""
268-
self.commit_date = ""
266+
self.date = ""
267+
self.committer = ""
268+
self.commit_date = ""
269269
self.commit_sha1 = ""
270270
self.parent_sha1 = [ ]
271271
self.parse_commit(commit_lines)
@@ -391,7 +391,7 @@ class DiffWindow:
391391
sourceview.show()
392392

393393

394-
def set_diff(self, commit_sha1, parent_sha1):
394+
def set_diff(self, commit_sha1, parent_sha1, encoding):
395395
"""Set the differences showed by this window.
396396
Compares the two trees and populates the window with the
397397
differences.
@@ -401,7 +401,7 @@ class DiffWindow:
401401
return
402402

403403
fp = os.popen("git diff-tree -p " + parent_sha1 + " " + commit_sha1)
404-
self.buffer.set_text(fp.read())
404+
self.buffer.set_text(unicode(fp.read(), encoding).encode('utf-8'))
405405
fp.close()
406406
self.window.show()
407407

@@ -426,10 +426,11 @@ class GitView:
426426

427427
def __init__(self, with_diff=0):
428428
self.with_diff = with_diff
429-
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
429+
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
430430
self.window.set_border_width(0)
431431
self.window.set_title("Git repository browser")
432432

433+
self.get_encoding()
433434
self.get_bt_sha1()
434435

435436
# Use three-quarters of the screen by default
@@ -468,6 +469,13 @@ class GitView:
468469
self.bt_sha1[sha1].append(name)
469470
fp.close()
470471

472+
def get_encoding(self):
473+
fp = os.popen("git repo-config --get i18n.commitencoding")
474+
self.encoding=string.strip(fp.readline())
475+
fp.close()
476+
if (self.encoding == ""):
477+
self.encoding = "utf-8"
478+
471479

472480
def construct(self):
473481
"""Construct the window contents."""
@@ -683,7 +691,7 @@ class GitView:
683691
self.revid_label.set_text(revid_label)
684692
self.committer_label.set_text(committer)
685693
self.timestamp_label.set_text(timestamp)
686-
self.message_buffer.set_text(message)
694+
self.message_buffer.set_text(unicode(message, self.encoding).encode('utf-8'))
687695

688696
for widget in self.parents_widgets:
689697
self.table.remove(widget)
@@ -728,7 +736,7 @@ class GitView:
728736
button.set_relief(gtk.RELIEF_NONE)
729737
button.set_sensitive(True)
730738
button.connect("clicked", self._show_clicked_cb,
731-
commit.commit_sha1, parent_id)
739+
commit.commit_sha1, parent_id, self.encoding)
732740
hbox.pack_start(button, expand=False, fill=True)
733741
button.show()
734742

@@ -870,15 +878,15 @@ class GitView:
870878

871879
# Reset nodepostion
872880
if (last_nodepos > 5):
873-
last_nodepos = -1
881+
last_nodepos = -1
874882

875883
# Add the incomplete lines of the last cell in this
876884
try:
877885
colour = self.colours[commit.commit_sha1]
878886
except KeyError:
879887
self.colours[commit.commit_sha1] = last_colour+1
880-
last_colour = self.colours[commit.commit_sha1]
881-
colour = self.colours[commit.commit_sha1]
888+
last_colour = self.colours[commit.commit_sha1]
889+
colour = self.colours[commit.commit_sha1]
882890

883891
try:
884892
node_pos = self.nodepos[commit.commit_sha1]
@@ -910,7 +918,7 @@ class GitView:
910918
self.colours[parent_id] = last_colour+1
911919
last_colour = self.colours[parent_id]
912920
self.nodepos[parent_id] = last_nodepos+1
913-
last_nodepos = self.nodepos[parent_id]
921+
last_nodepos = self.nodepos[parent_id]
914922

915923
in_line.append((node_pos, self.nodepos[parent_id],
916924
self.colours[parent_id]))
@@ -946,7 +954,7 @@ class GitView:
946954
try:
947955
next_commit = self.commits[index+1]
948956
if (next_commit.commit_sha1 == sha1 and pos != int(pos)):
949-
# join the line back to the node point
957+
# join the line back to the node point
950958
# This need to be done only if we modified it
951959
in_line.append((pos, pos-0.5, self.colours[sha1]))
952960
continue;
@@ -967,10 +975,10 @@ class GitView:
967975

968976
self.treeview.grab_focus()
969977

970-
def _show_clicked_cb(self, widget, commit_sha1, parent_sha1):
978+
def _show_clicked_cb(self, widget, commit_sha1, parent_sha1, encoding):
971979
"""Callback for when the show button for a parent is clicked."""
972980
window = DiffWindow()
973-
window.set_diff(commit_sha1, parent_sha1)
981+
window.set_diff(commit_sha1, parent_sha1, encoding)
974982
self.treeview.grab_focus()
975983

976984
if __name__ == "__main__":

git-format-patch.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ titleScript='
174174
process_one () {
175175
perl -w -e '
176176
my ($keep_subject, $num, $signoff, $commsg) = @ARGV;
177-
my ($signoff_pattern, $done_header, $done_subject, $signoff_seen,
177+
my ($signoff_pattern, $done_header, $done_subject, $done_separator, $signoff_seen,
178178
$last_was_signoff);
179179
180180
if ($signoff) {
@@ -228,6 +228,11 @@ while (<FH>) {
228228
$done_subject = 1;
229229
next;
230230
}
231+
unless ($done_separator) {
232+
print "\n";
233+
$done_separator = 1;
234+
next if (/^$/);
235+
}
231236
232237
$last_was_signoff = 0;
233238
if (/Signed-off-by:/i) {

0 commit comments

Comments
 (0)