Browse Source

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
maint
Junio C Hamano 16 years ago
parent
commit
130b04ab37
  1. 7
      Documentation/git-pack-objects.txt
  2. 4
      builtin-pack-objects.c
  3. 2
      cache.h
  4. 6
      commit.c
  5. 1
      environment.c
  6. 2
      git-repack.sh
  7. 12
      t/t7700-repack.sh

7
Documentation/git-pack-objects.txt

@ -11,7 +11,8 @@ SYNOPSIS
[verse] [verse]
'git pack-objects' [-q] [--no-reuse-delta] [--delta-base-offset] [--non-empty] 'git pack-objects' [-q] [--no-reuse-delta] [--delta-base-offset] [--non-empty]
[--local] [--incremental] [--window=N] [--depth=N] [--all-progress] [--local] [--incremental] [--window=N] [--depth=N] [--all-progress]
[--revs [--unpacked | --all]*] [--stdout | base-name] < object-list [--revs [--unpacked | --all]*] [--stdout | base-name]
[--keep-true-parents] < object-list




DESCRIPTION DESCRIPTION
@ -197,6 +198,10 @@ base-name::
to force the version for the generated pack index, and to force to force the version for the generated pack index, and to force
64-bit index entries on objects located above the given offset. 64-bit index entries on objects located above the given offset.


--keep-true-parents::
With this option, parents that are hidden by grafts are packed
nevertheless.



Author Author
------ ------

4
builtin-pack-objects.c

@ -2255,6 +2255,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
die("bad %s", arg); die("bad %s", arg);
continue; continue;
} }
if (!strcmp(arg, "--keep-true-parents")) {
grafts_replace_parents = 0;
continue;
}
usage(pack_usage); usage(pack_usage);
} }



2
cache.h

@ -560,6 +560,8 @@ enum object_creation_mode {


extern enum object_creation_mode object_creation_mode; extern enum object_creation_mode object_creation_mode;


extern int grafts_replace_parents;

#define GIT_REPO_VERSION 0 #define GIT_REPO_VERSION 0
extern int repository_format_version; extern int repository_format_version;
extern int check_repository_format(void); extern int check_repository_format(void);

6
commit.c

@ -262,7 +262,11 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
bufptr[47] != '\n') bufptr[47] != '\n')
return error("bad parents in commit %s", sha1_to_hex(item->object.sha1)); return error("bad parents in commit %s", sha1_to_hex(item->object.sha1));
bufptr += 48; 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; continue;
new_parent = lookup_commit(parent); new_parent = lookup_commit(parent);
if (new_parent) if (new_parent)

1
environment.c

@ -47,6 +47,7 @@ enum push_default_type push_default = PUSH_DEFAULT_MATCHING;
#define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
#endif #endif
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE; enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
int grafts_replace_parents = 1;


/* Parallel index stat data preload? */ /* Parallel index stat data preload? */
int core_preload_index = 0; int core_preload_index = 0;

2
git-repack.sh

@ -81,7 +81,7 @@ case ",$all_into_one," in
esac esac


args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra" args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra"
names=$(git pack-objects --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") || names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
exit 1 exit 1
if [ -z "$names" ]; then if [ -z "$names" ]; then
say Nothing new to pack. say Nothing new to pack.

12
t/t7700-repack.sh

@ -149,5 +149,17 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar
test_must_fail git show $csha1 test_must_fail git show $csha1
' '


test_expect_success 'objects made unreachable by grafts only are kept' '
test_tick &&
git commit --allow-empty -m "commit 4" &&
H0=$(git rev-parse HEAD) &&
H1=$(git rev-parse HEAD^) &&
H2=$(git rev-parse HEAD^^) &&
echo "$H0 $H2" > .git/info/grafts &&
git reflog expire --expire=now --expire-unreachable=now --all &&
git repack -a -d &&
git cat-file -t $H1
'

test_done test_done



Loading…
Cancel
Save