From: Junio C Hamano Date: Sat, 25 Jul 2009 07:45:03 +0000 (-0700) Subject: Merge branch 'js/maint-graft-unhide-true-parents' X-Git-Tag: v1.6.4-rc3~7 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/130b04ab37d74e574d525df7948b963b13c6bdbf?ds=inline;hp=-c Merge branch 'js/maint-graft-unhide-true-parents' * js/maint-graft-unhide-true-parents: git repack: keep commits hidden by a graft Add a test showing that 'git repack' throws away grafted-away parents Conflicts: git-repack.sh --- 130b04ab37d74e574d525df7948b963b13c6bdbf diff --combined builtin-pack-objects.c index a27c2f6277,527638168b..ef4bf6bc14 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@@ -536,9 -536,11 +536,9 @@@ static void write_pack_file(void base_name, sha1_to_hex(sha1)); free_pack_by_name(tmpname); if (adjust_perm(pack_tmp_name, mode)) - die("unable to make temporary pack file readable: %s", - strerror(errno)); + die_errno("unable to make temporary pack file readable"); if (rename(pack_tmp_name, tmpname)) - die("unable to rename temporary pack file: %s", - strerror(errno)); + die_errno("unable to rename temporary pack file"); /* * Packs are runtime accessed in their mtime @@@ -564,9 -566,11 +564,9 @@@ snprintf(tmpname, sizeof(tmpname), "%s-%s.idx", base_name, sha1_to_hex(sha1)); if (adjust_perm(idx_tmp_name, mode)) - die("unable to make temporary index file readable: %s", - strerror(errno)); + die_errno("unable to make temporary index file readable"); if (rename(idx_tmp_name, tmpname)) - die("unable to rename temporary index file: %s", - strerror(errno)); + die_errno("unable to rename temporary index file"); free(idx_tmp_name); free(pack_tmp_name); @@@ -1875,7 -1879,7 +1875,7 @@@ static void read_object_list_from_stdin if (!ferror(stdin)) die("fgets returned NULL, not EOF, not error!"); if (errno != EINTR) - die("fgets: %s", strerror(errno)); + die_errno("fgets"); clearerr(stdin); continue; } @@@ -2255,6 -2259,10 +2255,10 @@@ int cmd_pack_objects(int argc, const ch die("bad %s", arg); continue; } + if (!strcmp(arg, "--keep-true-parents")) { + grafts_replace_parents = 0; + continue; + } usage(pack_usage); } diff --combined cache.h index c72f125bd4,e902008297..e6c7f3307d --- a/cache.h +++ b/cache.h @@@ -543,6 -543,7 +543,6 @@@ enum rebase_setup_type }; enum push_default_type { - PUSH_DEFAULT_UNSPECIFIED = -1, PUSH_DEFAULT_NOTHING = 0, PUSH_DEFAULT_MATCHING, PUSH_DEFAULT_TRACKING, @@@ -560,6 -561,8 +560,8 @@@ enum object_creation_mode extern enum object_creation_mode object_creation_mode; + extern int grafts_replace_parents; + #define GIT_REPO_VERSION 0 extern int repository_format_version; extern int check_repository_format(void); @@@ -613,8 -616,6 +615,8 @@@ extern int is_empty_blob_sha1(const uns int git_mkstemp(char *path, size_t n, const char *template); +int git_mkstemps(char *path, size_t n, const char *template, int suffix_len); + /* * NOTE NOTE NOTE!! * @@@ -743,17 -744,7 +745,17 @@@ struct checkout }; extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath); + +struct cache_def { + char path[PATH_MAX + 1]; + int len; + int flags; + int track_flags; + int prefix_len_stat_func; +}; + extern int has_symlink_leading_path(const char *name, int len); +extern int threaded_has_symlink_leading_path(struct cache_def *, const char *, int); extern int has_symlink_or_noent_leading_path(const char *name, int len); extern int has_dirs_only_path(const char *name, int len, int prefix_len); extern void invalidate_lstat_cache(const char *name, int len); diff --combined commit.c index a47fb4da27,f69525a089..e2bcbe8149 --- a/commit.c +++ b/commit.c @@@ -50,6 -50,7 +50,6 @@@ struct commit *lookup_commit(const unsi static unsigned long parse_commit_date(const char *buf, const char *tail) { - unsigned long date; const char *dateptr; if (buf + 6 >= tail) @@@ -72,7 -73,10 +72,7 @@@ if (buf >= tail) return 0; /* dateptr < buf && buf[-1] == '\n', so strtoul will stop at buf-1 */ - date = strtoul(dateptr, NULL, 10); - if (date == ULONG_MAX) - date = 0; - return date; + return strtoul(dateptr, NULL, 10); } static struct commit_graft **commit_graft; @@@ -262,7 -266,11 +262,11 @@@ int parse_commit_buffer(struct commit * bufptr[47] != '\n') return error("bad parents in commit %s", sha1_to_hex(item->object.sha1)); bufptr += 48; - if (graft) + /* + * The clone is shallow if nr_parent < 0, and we must + * not traverse its real parents even when we unhide them. + */ + if (graft && (graft->nr_parent < 0 || grafts_replace_parents)) continue; new_parent = lookup_commit(parent); if (new_parent) diff --combined environment.c index 720f26b67d,477d2e4da8..8f5eaa7dd8 --- a/environment.c +++ b/environment.c @@@ -42,11 -42,12 +42,12 @@@ enum safe_crlf safe_crlf = SAFE_CRLF_WA unsigned whitespace_rule_cfg = WS_DEFAULT_RULE; enum branch_track git_branch_track = BRANCH_TRACK_REMOTE; enum rebase_setup_type autorebase = AUTOREBASE_NEVER; -enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED; +enum push_default_type push_default = PUSH_DEFAULT_MATCHING; #ifndef OBJECT_CREATION_MODE #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS #endif enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE; + int grafts_replace_parents = 1; /* Parallel index stat data preload? */ int core_preload_index = 0; diff --combined git-repack.sh index 1bf239499c,be0c8435dc..1eb3bca352 --- a/git-repack.sh +++ b/git-repack.sh @@@ -24,7 -24,7 +24,7 @@@ SUBDIRECTORY_OK='Yes . git-sh-setup no_update_info= all_into_one= remove_redundant= unpack_unreachable= -local= quiet= no_reuse= extra= +local= no_reuse= extra= while test $# != 0 do case "$1" in @@@ -33,7 -33,7 +33,7 @@@ -A) all_into_one=t unpack_unreachable=--unpack-unreachable ;; -d) remove_redundant=t ;; - -q) quiet=-q ;; + -q) GIT_QUIET=t ;; -f) no_reuse=--no-reuse-object ;; -l) local=--local ;; --max-pack-size|--window|--window-memory|--depth) @@@ -80,11 -80,13 +80,11 @@@ case ",$all_into_one," i ;; esac -args="$args $local $quiet $no_reuse$extra" +args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra" - names=$(git pack-objects --honor-pack-keep --non-empty --all --reflog $args