From c9b6782a08a728908bac8dc51def3607b3daa2a9 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 16 Mar 2011 01:59:10 -0500 Subject: enums: omit trailing comma for portability Since v1.7.2-rc0~23^2~2 (Add per-repository eol normalization, 2010-05-19), building with gcc -std=gnu89 -pedantic produces warnings like the following: convert.c:21:11: warning: comma at end of enumerator list [-pedantic] gcc is right to complain --- these commas are not permitted in C89. In the spirit of v1.7.2-rc0~32^2~16 (2010-05-14), remove them. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/cache.h b/cache.h index c7b0a28..39ca875 100644 --- a/cache.h +++ b/cache.h @@ -570,7 +570,7 @@ extern enum safe_crlf safe_crlf; enum auto_crlf { AUTO_CRLF_FALSE = 0, AUTO_CRLF_TRUE = 1, - AUTO_CRLF_INPUT = -1, + AUTO_CRLF_INPUT = -1 }; extern enum auto_crlf auto_crlf; diff --git a/convert.c b/convert.c index d5aebed..7eb51b1 100644 --- a/convert.c +++ b/convert.c @@ -18,7 +18,7 @@ enum action { CRLF_TEXT, CRLF_INPUT, CRLF_CRLF, - CRLF_AUTO, + CRLF_AUTO }; struct text_stat { -- cgit v0.10.2-6-g49f6 From c6c8d0b797e33ce1f22d50b46d9c6eba91ed2cbc Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 16 Mar 2011 02:00:49 -0500 Subject: compat: make gcc bswap an inline function Without this change, gcc -pedantic warns: cache.h: In function 'ce_to_dtype': cache.h:270:21: warning: ISO C forbids braced-groups within expressions [-pedantic] An inline function is more readable anyway. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/compat/bswap.h b/compat/bswap.h index 54756db..5061214 100644 --- a/compat/bswap.h +++ b/compat/bswap.h @@ -21,14 +21,16 @@ static inline uint32_t default_swab32(uint32_t val) #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) -#define bswap32(x) ({ \ - uint32_t __res; \ - if (__builtin_constant_p(x)) { \ - __res = default_swab32(x); \ - } else { \ - __asm__("bswap %0" : "=r" (__res) : "0" ((uint32_t)(x))); \ - } \ - __res; }) +#define bswap32 git_bswap32 +static inline uint32_t git_bswap32(uint32_t x) +{ + uint32_t result; + if (__builtin_constant_p(x)) + result = default_swab32(x); + else + __asm__("bswap %0" : "=r" (result) : "0" (x)); + return result; +} #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) -- cgit v0.10.2-6-g49f6 From 9cba13ca5d233a4e1a7068f3f5ed5836a081dcc0 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 16 Mar 2011 02:08:34 -0500 Subject: standardize brace placement in struct definitions In a struct definitions, unlike functions, the prevailing style is for the opening brace to go on the same line as the struct name, like so: struct foo { int bar; char *baz; }; Indeed, grepping for 'struct [a-z_]* {$' yields about 5 times as many matches as 'struct [a-z_]*$'. Linus sayeth: Heretic people all over the world have claimed that this inconsistency is ... well ... inconsistent, but all right-thinking people know that (a) K&R are _right_ and (b) K&R are right. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/builtin/add.c b/builtin/add.c index 42c906e..1d74763 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -21,8 +21,7 @@ static const char * const builtin_add_usage[] = { static int patch_interactive, add_interactive, edit_interactive; static int take_worktree_changes; -struct update_callback_data -{ +struct update_callback_data { int flags; int add_errors; }; diff --git a/builtin/blame.c b/builtin/blame.c index aa30ec5..f6b03f7 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -1312,8 +1312,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt) /* * Information on commits, used for output. */ -struct commit_info -{ +struct commit_info { const char *author; const char *author_mail; unsigned long author_time; diff --git a/builtin/grep.c b/builtin/grep.c index fdf7131..34f9ae0 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -40,8 +40,7 @@ enum work_type {WORK_SHA1, WORK_FILE}; * threads. The producer adds struct work_items to 'todo' and the * consumers pick work items from the same array. */ -struct work_item -{ +struct work_item { enum work_type type; char *name; diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 8dc5c0b..c7e600d 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -13,8 +13,7 @@ static const char index_pack_usage[] = "git index-pack [-v] [-o ] [ --keep | --keep= ] [--strict] ( | --stdin [--fix-thin] [])"; -struct object_entry -{ +struct object_entry { struct pack_idx_entry idx; unsigned long size; unsigned int hdr_size; @@ -44,8 +43,7 @@ struct base_data { #define FLAG_LINK (1u<<20) #define FLAG_CHECKED (1u<<21) -struct delta_entry -{ +struct delta_entry { union delta_base base; int obj_no; }; diff --git a/commit.h b/commit.h index 659c87c..4198513 100644 --- a/commit.h +++ b/commit.h @@ -68,8 +68,7 @@ enum cmit_fmt { CMIT_FMT_UNSPECIFIED }; -struct pretty_print_context -{ +struct pretty_print_context { int abbrev; const char *subject; const char *after_subject; diff --git a/config.c b/config.c index 47e6ba5..3dd55d5 100644 --- a/config.c +++ b/config.c @@ -20,8 +20,7 @@ static int zlib_compression_seen; const char *config_exclusive_filename = NULL; -struct config_item -{ +struct config_item { struct config_item *next; char *name; char *value; diff --git a/diff.c b/diff.c index 5422c43..2f2ab87 100644 --- a/diff.c +++ b/diff.c @@ -606,16 +606,14 @@ static void diff_words_append(char *line, unsigned long len, buffer->text.ptr[buffer->text.size] = '\0'; } -struct diff_words_style_elem -{ +struct diff_words_style_elem { const char *prefix; const char *suffix; const char *color; /* NULL; filled in by the setup code if * color is enabled */ }; -struct diff_words_style -{ +struct diff_words_style { enum diff_words_type type; struct diff_words_style_elem new, old, ctx; const char *newline; diff --git a/fast-import.c b/fast-import.c index 970d847..87f36b3 100644 --- a/fast-import.c +++ b/fast-import.c @@ -166,8 +166,7 @@ Format of STDIN stream: #define DEPTH_BITS 13 #define MAX_DEPTH ((1< Date: Wed, 16 Mar 2011 02:10:14 -0500 Subject: branch: split off function that writes tracking info and commit subject Introduce a add_verbose_info function that takes care of adding - an abbreviated object name; - a summary of the form [ahead x, behind y] of the relationship to the corresponding upstream branch; - a one line commit subject for the tip commit of a branch, for use in "git branch -v" output. No functional change intended. This just unindents the code a little and makes it easier to skip on first reading. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/builtin/branch.c b/builtin/branch.c index fe8f2fc..b9ba011 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -390,6 +390,30 @@ static int matches_merge_filter(struct commit *commit) return (is_merged == (merge_filter == SHOW_MERGED)); } +static void add_verbose_info(struct strbuf *out, struct ref_item *item, + int verbose, int abbrev) +{ + struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT; + const char *sub = " **** invalid ref ****"; + struct commit *commit = item->commit; + + if (commit && !parse_commit(commit)) { + struct pretty_print_context ctx = {0}; + pretty_print_commit(CMIT_FMT_ONELINE, commit, + &subject, &ctx); + sub = subject.buf; + } + + if (item->kind == REF_LOCAL_BRANCH) + fill_tracking_info(&stat, item->name, verbose > 1); + + strbuf_addf(out, " %s %s%s", + find_unique_abbrev(item->commit->object.sha1, abbrev), + stat.buf, sub); + strbuf_release(&stat); + strbuf_release(&subject); +} + static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, int abbrev, int current, char *prefix) { @@ -430,27 +454,9 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, if (item->dest) strbuf_addf(&out, " -> %s", item->dest); - else if (verbose) { - struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT; - const char *sub = " **** invalid ref ****"; - - commit = item->commit; - if (commit && !parse_commit(commit)) { - struct pretty_print_context ctx = {0}; - pretty_print_commit(CMIT_FMT_ONELINE, commit, - &subject, &ctx); - sub = subject.buf; - } - - if (item->kind == REF_LOCAL_BRANCH) - fill_tracking_info(&stat, item->name, verbose > 1); - - strbuf_addf(&out, " %s %s%s", - find_unique_abbrev(item->commit->object.sha1, abbrev), - stat.buf, sub); - strbuf_release(&stat); - strbuf_release(&subject); - } + else if (verbose) + /* " f7c0c00 [ahead 58, behind 197] vcs-svn: drop obj_pool.h" */ + add_verbose_info(&out, item, verbose, abbrev); printf("%s\n", out.buf); strbuf_release(&name); strbuf_release(&out); -- cgit v0.10.2-6-g49f6 From a3a32e7f083cdd3b8e68419d2f012b5561a9ccde Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 16 Mar 2011 02:12:48 -0500 Subject: cherry: split off function to print output lines Readers uninterested in the details of "git cherry"'s output format can see print_commit('-', commit, verbose, abbrev); and ignore the details. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/builtin/log.c b/builtin/log.c index d8c6c28..0f43d2e 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1352,6 +1352,23 @@ static const char * const cherry_usage[] = { NULL }; +static void print_commit(char sign, struct commit *commit, int verbose, + int abbrev) +{ + if (!verbose) { + printf("%c %s\n", sign, + find_unique_abbrev(commit->object.sha1, abbrev)); + } else { + struct strbuf buf = STRBUF_INIT; + struct pretty_print_context ctx = {0}; + pretty_print_commit(CMIT_FMT_ONELINE, commit, &buf, &ctx); + printf("%c %s %s\n", sign, + find_unique_abbrev(commit->object.sha1, abbrev), + buf.buf); + strbuf_release(&buf); + } +} + int cmd_cherry(int argc, const char **argv, const char *prefix) { struct rev_info revs; @@ -1436,22 +1453,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) commit = list->item; if (has_commit_patch_id(commit, &ids)) sign = '-'; - - if (verbose) { - struct strbuf buf = STRBUF_INIT; - struct pretty_print_context ctx = {0}; - pretty_print_commit(CMIT_FMT_ONELINE, commit, - &buf, &ctx); - printf("%c %s %s\n", sign, - find_unique_abbrev(commit->object.sha1, abbrev), - buf.buf); - strbuf_release(&buf); - } - else { - printf("%c %s\n", sign, - find_unique_abbrev(commit->object.sha1, abbrev)); - } - + print_commit(sign, commit, verbose, abbrev); list = list->next; } -- cgit v0.10.2-6-g49f6 From 808a95dcad957ce00dc6fde7cf7f53ca32200c34 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 16 Mar 2011 02:14:11 -0500 Subject: diff --submodule: split into bite-sized pieces Introduce two functions: - prepare_submodule_summary prepares the revision walker to list changes in a submodule. That is, it: * finds merge bases between the commits pointed to this path from before ("left") and after ("right") the change; * checks whether this is a fast-forward or fast-backward; * prepares a revision walk to list commits in the symmetric difference between the commits at each endpoint. It returns nonzero on error. - print_submodule_summary runs the revision walk and saves the result to a strbuf in --left-right format. The goal is just readability. No functional change intended. Signed-off-by: Jonathan Nieder Acked-by: Jens Lehmann Signed-off-by: Junio C Hamano diff --git a/submodule.c b/submodule.c index 6f1c107..e9f2b19 100644 --- a/submodule.c +++ b/submodule.c @@ -152,17 +152,69 @@ void handle_ignore_submodules_arg(struct diff_options *diffopt, die("bad --ignore-submodules argument: %s", arg); } +static int prepare_submodule_summary(struct rev_info *rev, const char *path, + struct commit *left, struct commit *right, + int *fast_forward, int *fast_backward) +{ + struct commit_list *merge_bases, *list; + + init_revisions(rev, NULL); + setup_revisions(0, NULL, rev, NULL); + rev->left_right = 1; + rev->first_parent_only = 1; + left->object.flags |= SYMMETRIC_LEFT; + add_pending_object(rev, &left->object, path); + add_pending_object(rev, &right->object, path); + merge_bases = get_merge_bases(left, right, 1); + if (merge_bases) { + if (merge_bases->item == left) + *fast_forward = 1; + else if (merge_bases->item == right) + *fast_backward = 1; + } + for (list = merge_bases; list; list = list->next) { + list->item->object.flags |= UNINTERESTING; + add_pending_object(rev, &list->item->object, + sha1_to_hex(list->item->object.sha1)); + } + return prepare_revision_walk(rev); +} + +static void print_submodule_summary(struct rev_info *rev, FILE *f, + const char *del, const char *add, const char *reset) +{ + static const char format[] = " %m %s"; + struct strbuf sb = STRBUF_INIT; + struct commit *commit; + + while ((commit = get_revision(rev))) { + struct pretty_print_context ctx = {0}; + ctx.date_mode = rev->date_mode; + strbuf_setlen(&sb, 0); + if (commit->object.flags & SYMMETRIC_LEFT) { + if (del) + strbuf_addstr(&sb, del); + } + else if (add) + strbuf_addstr(&sb, add); + format_commit_message(commit, format, &sb, &ctx); + if (reset) + strbuf_addstr(&sb, reset); + strbuf_addch(&sb, '\n'); + fprintf(f, "%s", sb.buf); + } + strbuf_release(&sb); +} + void show_submodule_summary(FILE *f, const char *path, unsigned char one[20], unsigned char two[20], unsigned dirty_submodule, const char *del, const char *add, const char *reset) { struct rev_info rev; - struct commit *commit, *left = left, *right = right; - struct commit_list *merge_bases, *list; + struct commit *left = left, *right = right; const char *message = NULL; struct strbuf sb = STRBUF_INIT; - static const char *format = " %m %s"; int fast_forward = 0, fast_backward = 0; if (is_null_sha1(two)) @@ -175,29 +227,10 @@ void show_submodule_summary(FILE *f, const char *path, !(right = lookup_commit_reference(two))) message = "(commits not present)"; - if (!message) { - init_revisions(&rev, NULL); - setup_revisions(0, NULL, &rev, NULL); - rev.left_right = 1; - rev.first_parent_only = 1; - left->object.flags |= SYMMETRIC_LEFT; - add_pending_object(&rev, &left->object, path); - add_pending_object(&rev, &right->object, path); - merge_bases = get_merge_bases(left, right, 1); - if (merge_bases) { - if (merge_bases->item == left) - fast_forward = 1; - else if (merge_bases->item == right) - fast_backward = 1; - } - for (list = merge_bases; list; list = list->next) { - list->item->object.flags |= UNINTERESTING; - add_pending_object(&rev, &list->item->object, - sha1_to_hex(list->item->object.sha1)); - } - if (prepare_revision_walk(&rev)) - message = "(revision walker failed)"; - } + if (!message && + prepare_submodule_summary(&rev, path, left, right, + &fast_forward, &fast_backward)) + message = "(revision walker failed)"; if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED) fprintf(f, "Submodule %s contains untracked content\n", path); @@ -221,25 +254,11 @@ void show_submodule_summary(FILE *f, const char *path, fwrite(sb.buf, sb.len, 1, f); if (!message) { - while ((commit = get_revision(&rev))) { - struct pretty_print_context ctx = {0}; - ctx.date_mode = rev.date_mode; - strbuf_setlen(&sb, 0); - if (commit->object.flags & SYMMETRIC_LEFT) { - if (del) - strbuf_addstr(&sb, del); - } - else if (add) - strbuf_addstr(&sb, add); - format_commit_message(commit, format, &sb, &ctx); - if (reset) - strbuf_addstr(&sb, reset); - strbuf_addch(&sb, '\n'); - fprintf(f, "%s", sb.buf); - } + print_submodule_summary(&rev, f, del, add, reset); clear_commit_marks(left, ~0); clear_commit_marks(right, ~0); } + strbuf_release(&sb); } -- cgit v0.10.2-6-g49f6 From b406a2d3e30b1930ea3dc812bd1c4422ae135d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Wed, 16 Mar 2011 12:46:01 +0100 Subject: valgrind: ignore SSE-based strlen invalid reads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some versions of strlen use SSE to speed up the calculation and load 4 bytes at a time, even if it means reading past the end of the allocated memory. This read is safe and when the strlen function is inlined, it is not replaced by valgrind, which reports a false-possitive. Tell valgrind to ignore this particular error, as the read is, in fact, safe. Current upstream-released version 3.6.1 is affected. Some distributions have this fixed in their latest versions. Signed-off-by: Carlos Martín Nieto Signed-off-by: Junio C Hamano diff --git a/t/valgrind/default.supp b/t/valgrind/default.supp index 9e013fa..0a6724f 100644 --- a/t/valgrind/default.supp +++ b/t/valgrind/default.supp @@ -43,3 +43,9 @@ fun:write_buffer fun:write_loose_object } + +{ + ignore-sse-strlen-invalid-read-size + Memcheck:Addr4 + fun:copy_ref +} -- cgit v0.10.2-6-g49f6 From 1d679de58e886e134c5569c542667a08f0faedd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Wed, 16 Mar 2011 17:06:17 +0100 Subject: make_absolute_path: return the input path if it points to our buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some codepaths call make_absolute_path with its own return value as input. In such a cases, return the path immediately. This fixes a valgrind-discovered error, whereby we tried to copy a string onto itself. Signed-off-by: Carlos Martín Nieto Signed-off-by: Junio C Hamano diff --git a/abspath.c b/abspath.c index 91ca00f..ff14068 100644 --- a/abspath.c +++ b/abspath.c @@ -24,6 +24,10 @@ const char *make_absolute_path(const char *path) char *last_elem = NULL; struct stat st; + /* We've already done it */ + if (path == buf || path == next_buf) + return path; + if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX) die ("Too long path: %.*s", 60, path); -- cgit v0.10.2-6-g49f6 From 6affdbe677c4b2b8547bd9aa471464dd31a94a1c Mon Sep 17 00:00:00 2001 From: Kevin Cernekee Date: Wed, 16 Mar 2011 15:34:13 -0700 Subject: gitweb: highlight: replace tabs with spaces Consider the following code fragment: /* * test */ vim ":set list" mode shows that the first character on each line is a tab: ^I/*$ ^I * test$ ^I */$ By default, the "highlight" program will retain the tabs in the HTML output: $ highlight --fragment --syntax c test.c /* * test */ vim list mode: ^I/*$ ^I * test$ ^I */$ In gitweb, this winds up looking something like: 1 /* 2 * test 3 */ I tried both Firefox and Opera and saw the same behavior. The desired output is: 1 /* 2 * test 3 */ This can be accomplished by specifying "--replace-tabs=8" on the highlight command line. Signed-off-by: Kevin Cernekee Acked-by: John 'Warthog9' Hawley Signed-off-by: Junio C Hamano diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 1b9369d..b04ab8c 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -3468,7 +3468,7 @@ sub run_highlighter { close $fd; open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ". quote_command($highlight_bin). - " --fragment --syntax $syntax |" + " --replace-tabs=8 --fragment --syntax $syntax |" or die_error(500, "Couldn't open file or run syntax highlighter"); return $fd; } -- cgit v0.10.2-6-g49f6 From fbcda3c0a72cbcc105100ebef1b1dae54d854204 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 16 Mar 2011 16:29:03 -0700 Subject: Prepare draft release notes to 1.7.4.2 Signed-off-by: Junio C Hamano diff --git a/Documentation/RelNotes/1.7.4.2.txt b/Documentation/RelNotes/1.7.4.2.txt new file mode 100644 index 0000000..afb3871 --- /dev/null +++ b/Documentation/RelNotes/1.7.4.2.txt @@ -0,0 +1,42 @@ +Git v1.7.4.2 Release Notes +========================== + +Fixes since v1.7.4.1 +-------------------- + + * Many documentation updates to match "git cmd -h" output and the + git-cmd manual page. + + * "git clone /no/such/path" did not fail correctly. + + * "git commit" did not correctly error out when the user asked to use a + non existent file as the commit message template. + + * "git diff --stat -B" ran on binary files counted the changes in lines, + which was nonsensical. + + * "git diff -M" opportunistically detected copies, which was not + necessarily a good thing, especially when it is internally run by + recursive merge. + + * "git difftool" didn't tell (g)vimdiff that the files it is reading are + to be opened read-only. + + * "git merge" didn't pay attention to prepare-commit-msg hook, even + though if a merge is conflicted and manually resolved, the subsequent + "git commit" would have triggered the hook, which was inconsistent. + + * "git patch-id" (and commands like "format-patch --ignore-in-upstream" + that use it as their internal logic) handled changes to files that end + with incomplete lines incorrectly. + + * The official value to tell "git push" to push the current branch back + to update the upstream branch it forked from is now called "upstream". + The old name "tracking" is and will be supported. + + * gitweb's "highlight" interface mishandled tabs. + + * gitweb had a few forward-incompatible syntactic constructs and + also used incorrect variable when showing the file mode in a diff. + +And other minor fixes and documentation updates. diff --git a/RelNotes b/RelNotes index 0362cfa..9a74955 120000 --- a/RelNotes +++ b/RelNotes @@ -1 +1 @@ -Documentation/RelNotes/1.7.4.1.txt \ No newline at end of file +Documentation/RelNotes/1.7.4.2.txt \ No newline at end of file -- cgit v0.10.2-6-g49f6