summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/diff-options.txt3
-rw-r--r--Documentation/git-check-ignore.txt10
-rw-r--r--Documentation/git-send-email.txt11
-rw-r--r--Documentation/git-update-index.txt1
-rw-r--r--Documentation/git.txt12
-rw-r--r--Makefile13
-rw-r--r--block-sha1/sha1.h8
-rw-r--r--builtin/blame.c30
-rw-r--r--builtin/commit.c3
-rw-r--r--builtin/grep.c17
-rw-r--r--builtin/show-ref.c12
-rw-r--r--cache.h28
-rw-r--r--compat/apple-common-crypto.h4
-rw-r--r--compat/sha1-chunked.c19
-rw-r--r--compat/sha1-chunked.h2
-rw-r--r--configure.ac8
-rw-r--r--contrib/completion/git-completion.bash16
-rwxr-xr-xcontrib/rerere-train.sh2
-rwxr-xr-xcontrib/subtree/git-subtree.sh2
-rw-r--r--contrib/subtree/t/Makefile31
-rwxr-xr-xcontrib/subtree/t/t7900-subtree.sh1366
-rw-r--r--contrib/subtree/todo2
-rw-r--r--fsck.c3
-rwxr-xr-xgit-filter-branch.sh25
-rwxr-xr-xgit-p4.py100
-rw-r--r--git-rebase--interactive.sh2
-rwxr-xr-xgit-send-email.perl20
-rw-r--r--http.c23
-rw-r--r--parse-options.c40
-rw-r--r--parse-options.h2
-rw-r--r--ppc/sha1.h8
-rw-r--r--t/annotate-tests.sh7
-rw-r--r--t/lib-git-p4.sh71
-rwxr-xr-xt/perf/p7000-filter-branch.sh19
-rwxr-xr-xt/t1450-fsck.sh32
-rwxr-xr-xt/t5571-pre-push-hook.sh33
-rwxr-xr-xt/t5813-proto-disable-ssh.sh4
-rwxr-xr-xt/t7003-filter-branch.sh7
-rwxr-xr-xt/t9001-send-email.sh82
-rwxr-xr-xt/t9300-fast-import.sh3581
-rwxr-xr-xt/t9800-git-p4-basic.sh16
-rwxr-xr-xt/t9807-git-p4-submit.sh2
-rw-r--r--transport.c11
43 files changed, 3281 insertions, 2407 deletions
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index d56ca90..306b7e3 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -267,6 +267,9 @@ expression to make sure that it matches all non-whitespace characters.
A match that contains a newline is silently truncated(!) at the
newline.
+
+For example, `--word-diff-regex=.` will treat each character as a word
+and, correspondingly, show differences character by character.
++
The regex can also be set via a diff driver or configuration option, see
linkgit:gitattributes[1] or linkgit:git-config[1]. Giving it explicitly
overrides any diff driver or configuration setting. Diff drivers
diff --git a/Documentation/git-check-ignore.txt b/Documentation/git-check-ignore.txt
index 59531ab..e94367a 100644
--- a/Documentation/git-check-ignore.txt
+++ b/Documentation/git-check-ignore.txt
@@ -16,10 +16,9 @@ DESCRIPTION
-----------
For each pathname given via the command-line or from a file via
-`--stdin`, show the pattern from .gitignore (or other input files to
-the exclude mechanism) that decides if the pathname is excluded or
-included. Later patterns within a file take precedence over earlier
-ones.
+`--stdin`, check whether the file is excluded by .gitignore (or other
+input files to the exclude mechanism) and output the path if it is
+excluded.
By default, tracked files are not shown at all since they are not
subject to exclude rules; but see `--no-index'.
@@ -32,7 +31,8 @@ OPTIONS
-v, --verbose::
Also output details about the matching pattern (if any)
- for each given pathname.
+ for each given pathname. For precedence rules within and
+ between exclude sources, see linkgit:gitignore[5].
--stdin::
Read pathnames from the standard input, one per line,
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index b9134d2..771a7b5 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -10,6 +10,7 @@ SYNOPSIS
--------
[verse]
'git send-email' [options] <file|directory|rev-list options>...
+'git send-email' --dump-aliases
DESCRIPTION
@@ -387,6 +388,16 @@ default to '--validate'.
Send emails even if safety checks would prevent it.
+Information
+~~~~~~~~~~~
+
+--dump-aliases::
+ Instead of the normal operation, dump the shorthand alias names from
+ the configured alias file(s), one per line in alphabetical order. Note,
+ this only includes the alias name and not its expanded email addresses.
+ See 'sendemail.aliasesfile' for more information about aliases.
+
+
CONFIGURATION
-------------
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index 1a296bc..3df9c26 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -17,6 +17,7 @@ SYNOPSIS
[--[no-]assume-unchanged]
[--[no-]skip-worktree]
[--ignore-submodules]
+ [--[no-|force-]untracked-cache]
[--really-refresh] [--unresolve] [--again | -g]
[--info-only] [--index-info]
[-z] [--stdin] [--index-version <n>]
diff --git a/Documentation/git.txt b/Documentation/git.txt
index c2e2a94..900272b 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -1056,7 +1056,7 @@ of clones and fetches.
cloning of shallow repositories.
See 'GIT_TRACE' for available trace output options.
-GIT_LITERAL_PATHSPECS::
+'GIT_LITERAL_PATHSPECS'::
Setting this variable to `1` will cause Git to treat all
pathspecs literally, rather than as glob patterns. For example,
running `GIT_LITERAL_PATHSPECS=1 git log -- '*.c'` will search
@@ -1065,15 +1065,15 @@ GIT_LITERAL_PATHSPECS::
literal paths to Git (e.g., paths previously given to you by
`git ls-tree`, `--raw` diff output, etc).
-GIT_GLOB_PATHSPECS::
+'GIT_GLOB_PATHSPECS'::
Setting this variable to `1` will cause Git to treat all
pathspecs as glob patterns (aka "glob" magic).
-GIT_NOGLOB_PATHSPECS::
+'GIT_NOGLOB_PATHSPECS'::
Setting this variable to `1` will cause Git to treat all
pathspecs as literal (aka "literal" magic).
-GIT_ICASE_PATHSPECS::
+'GIT_ICASE_PATHSPECS'::
Setting this variable to `1` will cause Git to treat all
pathspecs as case-insensitive.
@@ -1087,7 +1087,7 @@ GIT_ICASE_PATHSPECS::
variable when it is invoked as the top level command by the
end user, to be recorded in the body of the reflog.
-`GIT_REF_PARANOIA`::
+'GIT_REF_PARANOIA'::
If set to `1`, include broken or badly named refs when iterating
over lists of refs. In a normal, non-corrupted repository, this
does nothing. However, enabling it may help git to detect and
@@ -1098,7 +1098,7 @@ GIT_ICASE_PATHSPECS::
an operation has touched every ref (e.g., because you are
cloning a repository to make a backup).
-`GIT_ALLOW_PROTOCOL`::
+'GIT_ALLOW_PROTOCOL'::
If set, provide a colon-separated list of protocols which are
allowed to be used with fetch/push/clone. This is useful to
restrict recursive submodule initialization from an untrusted
diff --git a/Makefile b/Makefile
index 43ceeb9..bce79a1 100644
--- a/Makefile
+++ b/Makefile
@@ -142,6 +142,10 @@ all::
# Define PPC_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine optimized for PowerPC.
#
+# Define SHA1_MAX_BLOCK_SIZE to limit the amount of data that will be hashed
+# in one call to the platform's SHA1_Update(). e.g. APPLE_COMMON_CRYPTO
+# wants 'SHA1_MAX_BLOCK_SIZE=1024L*1024L*1024L' defined.
+#
# Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
#
# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
@@ -1338,6 +1342,11 @@ ifdef NO_POSIX_GOODIES
BASIC_CFLAGS += -DNO_POSIX_GOODIES
endif
+ifdef APPLE_COMMON_CRYPTO
+ # Apple CommonCrypto requires chunking
+ SHA1_MAX_BLOCK_SIZE = 1024L*1024L*1024L
+endif
+
ifdef BLK_SHA1
SHA1_HEADER = "block-sha1/sha1.h"
LIB_OBJS += block-sha1/sha1.o
@@ -1356,6 +1365,10 @@ endif
endif
endif
+ifdef SHA1_MAX_BLOCK_SIZE
+ LIB_OBJS += compat/sha1-chunked.o
+ BASIC_CFLAGS += -DSHA1_MAX_BLOCK_SIZE="$(SHA1_MAX_BLOCK_SIZE)"
+endif
ifdef NO_PERL_MAKEMAKER
export NO_PERL_MAKEMAKER
endif
diff --git a/block-sha1/sha1.h b/block-sha1/sha1.h
index b864df6..4df6747 100644
--- a/block-sha1/sha1.h
+++ b/block-sha1/sha1.h
@@ -16,7 +16,7 @@ void blk_SHA1_Init(blk_SHA_CTX *ctx);
void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, unsigned long len);
void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx);
-#define git_SHA_CTX blk_SHA_CTX
-#define git_SHA1_Init blk_SHA1_Init
-#define git_SHA1_Update blk_SHA1_Update
-#define git_SHA1_Final blk_SHA1_Final
+#define platform_SHA_CTX blk_SHA_CTX
+#define platform_SHA1_Init blk_SHA1_Init
+#define platform_SHA1_Update blk_SHA1_Update
+#define platform_SHA1_Final blk_SHA1_Final
diff --git a/builtin/blame.c b/builtin/blame.c
index 83612f5..2afe828 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2402,10 +2402,12 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
return commit;
}
-static struct object_array_entry *find_single_final(struct rev_info *revs)
+static struct commit *find_single_final(struct rev_info *revs,
+ const char **name_p)
{
int i;
- struct object_array_entry *found = NULL;
+ struct commit *found = NULL;
+ const char *name = NULL;
for (i = 0; i < revs->pending.nr; i++) {
struct object *obj = revs->pending.objects[i].item;
@@ -2417,22 +2419,20 @@ static struct object_array_entry *find_single_final(struct rev_info *revs)
die("Non commit %s?", revs->pending.objects[i].name);
if (found)
die("More than one commit to dig from %s and %s?",
- revs->pending.objects[i].name,
- found->name);
- found = &(revs->pending.objects[i]);
+ revs->pending.objects[i].name, name);
+ found = (struct commit *)obj;
+ name = revs->pending.objects[i].name;
}
+ if (name_p)
+ *name_p = name;
return found;
}
static char *prepare_final(struct scoreboard *sb)
{
- struct object_array_entry *found = find_single_final(sb->revs);
- if (found) {
- sb->final = (struct commit *) found->item;
- return xstrdup(found->name);
- } else {
- return NULL;
- }
+ const char *name;
+ sb->final = find_single_final(sb->revs, &name);
+ return xstrdup_or_null(name);
}
static char *prepare_initial(struct scoreboard *sb)
@@ -2720,11 +2720,9 @@ parse_done:
die("Cannot use --contents with final commit object name");
if (reverse && revs.first_parent_only) {
- struct object_array_entry *entry = find_single_final(sb.revs);
- if (!entry)
+ final_commit = find_single_final(sb.revs, NULL);
+ if (!final_commit)
die("--reverse and --first-parent together require specified latest commit");
- else
- final_commit = (struct commit*) entry->item;
}
/*
diff --git a/builtin/commit.c b/builtin/commit.c
index dca09e2..f2a8b78 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -32,6 +32,7 @@
#include "sequencer.h"
#include "notes-utils.h"
#include "mailmap.h"
+#include "sigchain.h"
static const char * const builtin_commit_usage[] = {
N_("git commit [<options>] [--] <pathspec>..."),
@@ -1537,8 +1538,10 @@ static int run_rewrite_hook(const unsigned char *oldsha1,
return code;
n = snprintf(buf, sizeof(buf), "%s %s\n",
sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
+ sigchain_push(SIGPIPE, SIG_IGN);
write_in_full(proc.in, buf, n);
close(proc.in);
+ sigchain_pop(SIGPIPE);
return finish_command(&proc);
}
diff --git a/builtin/grep.c b/builtin/grep.c
index d04f440..749e346 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -612,11 +612,6 @@ static int pattern_callback(const struct option *opt, const char *arg,
return 0;
}
-static int help_callback(const struct option *opt, const char *arg, int unset)
-{
- return -1;
-}
-
int cmd_grep(int argc, const char **argv, const char *prefix)
{
int hit = 0;
@@ -738,18 +733,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
PARSE_OPT_OPTARG, NULL, (intptr_t)default_pager },
OPT_BOOL(0, "ext-grep", &external_grep_allowed__ignored,
N_("allow calling of grep(1) (ignored by this build)")),
- { OPTION_CALLBACK, 0, "help-all", NULL, NULL, N_("show usage"),
- PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, help_callback },
OPT_END()
};
- /*
- * 'git grep -h', unlike 'git grep -h <pattern>', is a request
- * to show usage information and exit.
- */
- if (argc == 2 && !strcmp(argv[1], "-h"))
- usage_with_options(grep_usage, options);
-
init_grep_defaults();
git_config(grep_cmd_config, NULL);
grep_init(&opt, prefix);
@@ -766,8 +752,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
*/
argc = parse_options(argc, argv, prefix, options, grep_usage,
PARSE_OPT_KEEP_DASHDASH |
- PARSE_OPT_STOP_AT_NON_OPTION |
- PARSE_OPT_NO_INTERNAL_HELP);
+ PARSE_OPT_STOP_AT_NON_OPTION);
grep_commit_pattern_type(pattern_type_arg, &opt);
if (use_index && !startup_info->have_repository)
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 264c392..6d4e669 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -161,11 +161,6 @@ static int exclude_existing_callback(const struct option *opt, const char *arg,
return 0;
}
-static int help_callback(const struct option *opt, const char *arg, int unset)
-{
- return -1;
-}
-
static const struct option show_ref_options[] = {
OPT_BOOL(0, "tags", &tags_only, N_("only show tags (can be combined with heads)")),
OPT_BOOL(0, "heads", &heads_only, N_("only show heads (can be combined with tags)")),
@@ -186,18 +181,13 @@ static const struct option show_ref_options[] = {
{ OPTION_CALLBACK, 0, "exclude-existing", &exclude_existing_arg,
N_("pattern"), N_("show refs from stdin that aren't in local repository"),
PARSE_OPT_OPTARG | PARSE_OPT_NONEG, exclude_existing_callback },
- { OPTION_CALLBACK, 0, "help-all", NULL, NULL, N_("show usage"),
- PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, help_callback },
OPT_END()
};
int cmd_show_ref(int argc, const char **argv, const char *prefix)
{
- if (argc == 2 && !strcmp(argv[1], "-h"))
- usage_with_options(show_ref_usage, show_ref_options);
-
argc = parse_options(argc, argv, prefix, show_ref_options,
- show_ref_usage, PARSE_OPT_NO_INTERNAL_HELP);
+ show_ref_usage, 0);
if (exclude_arg)
return exclude_existing(exclude_existing_arg);
diff --git a/cache.h b/cache.h
index 736abc0..2a9e902 100644
--- a/cache.h
+++ b/cache.h
@@ -11,11 +11,29 @@
#include "string-list.h"
#include SHA1_HEADER
-#ifndef git_SHA_CTX
-#define git_SHA_CTX SHA_CTX
-#define git_SHA1_Init SHA1_Init
-#define git_SHA1_Update SHA1_Update
-#define git_SHA1_Final SHA1_Final
+#ifndef platform_SHA_CTX
+/*
+ * platform's underlying implementation of SHA-1; could be OpenSSL,
+ * blk_SHA, Apple CommonCrypto, etc... Note that including
+ * SHA1_HEADER may have already defined platform_SHA_CTX for our
+ * own implementations like block-sha1 and ppc-sha1, so we list
+ * the default for OpenSSL compatible SHA-1 implementations here.
+ */
+#define platform_SHA_CTX SHA_CTX
+#define platform_SHA1_Init SHA1_Init
+#define platform_SHA1_Update SHA1_Update
+#define platform_SHA1_Final SHA1_Final
+#endif
+
+#define git_SHA_CTX platform_SHA_CTX
+#define git_SHA1_Init platform_SHA1_Init
+#define git_SHA1_Update platform_SHA1_Update
+#define git_SHA1_Final platform_SHA1_Final
+
+#ifdef SHA1_MAX_BLOCK_SIZE
+#include "compat/sha1-chunked.h"
+#undef git_SHA1_Update
+#define git_SHA1_Update git_SHA1_Update_Chunked
#endif
#include <zlib.h>
diff --git a/compat/apple-common-crypto.h b/compat/apple-common-crypto.h
index c8b9b0e..d3fb264 100644
--- a/compat/apple-common-crypto.h
+++ b/compat/apple-common-crypto.h
@@ -16,6 +16,10 @@
#undef TYPE_BOOL
#endif
+#ifndef SHA1_MAX_BLOCK_SIZE
+#error Using Apple Common Crypto library requires setting SHA1_MAX_BLOCK_SIZE
+#endif
+
#ifdef APPLE_LION_OR_NEWER
#define git_CC_error_check(pattern, err) \
do { \
diff --git a/compat/sha1-chunked.c b/compat/sha1-chunked.c
new file mode 100644
index 0000000..6adfcfd
--- /dev/null
+++ b/compat/sha1-chunked.c
@@ -0,0 +1,19 @@
+#include "cache.h"
+
+int git_SHA1_Update_Chunked(platform_SHA_CTX *c, const void *data, size_t len)
+{
+ size_t nr;
+ size_t total = 0;
+ const char *cdata = (const char*)data;
+
+ while (len) {
+ nr = len;
+ if (nr > SHA1_MAX_BLOCK_SIZE)
+ nr = SHA1_MAX_BLOCK_SIZE;
+ platform_SHA1_Update(c, cdata, nr);
+ total += nr;
+ cdata += nr;
+ len -= nr;
+ }
+ return total;
+}
diff --git a/compat/sha1-chunked.h b/compat/sha1-chunked.h
new file mode 100644
index 0000000..7b2df28
--- /dev/null
+++ b/compat/sha1-chunked.h
@@ -0,0 +1,2 @@
+
+int git_SHA1_Update_Chunked(platform_SHA_CTX *c, const void *data, size_t len);
diff --git a/configure.ac b/configure.ac
index 76170ad..89e2590 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1142,7 +1142,12 @@ elif test -z "$PTHREAD_CFLAGS"; then
# would then trigger compiler warnings on every single file we compile.
for opt in "" -mt -pthread -lpthread; do
old_CFLAGS="$CFLAGS"
- CFLAGS="$opt $CFLAGS"
+ old_LIBS="$LIBS"
+ case "$opt" in
+ -l*) LIBS="$opt $LIBS" ;;
+ *) CFLAGS="$opt $CFLAGS" ;;
+ esac
+
AC_MSG_CHECKING([for POSIX Threads with '$opt'])
AC_LINK_IFELSE([PTHREADTEST_SRC],
[AC_MSG_RESULT([yes])
@@ -1154,6 +1159,7 @@ elif test -z "$PTHREAD_CFLAGS"; then
],
[AC_MSG_RESULT([no])])
CFLAGS="$old_CFLAGS"
+ LIBS="$old_LIBS"
done
if test $threads_found != yes; then
AC_CHECK_LIB([pthread], [pthread_create],
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 482ca84..111b053 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -10,6 +10,7 @@
# *) local and remote tag names
# *) .git/remotes file names
# *) git 'subcommands'
+# *) git email aliases for git-send-email
# *) tree paths within 'ref:path/to/file' expressions
# *) file paths within current working directory and index
# *) common --long-options
@@ -1711,6 +1712,15 @@ __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
_git_send_email ()
{
+ case "$prev" in
+ --to|--cc|--bcc|--from)
+ __gitcomp "
+ $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
+ " "" ""
+ return
+ ;;
+ esac
+
case "$cur" in
--confirm=*)
__gitcomp "
@@ -1735,6 +1745,12 @@ _git_send_email ()
" "" "${cur##--thread=}"
return
;;
+ --to=*|--cc=*|--bcc=*|--from=*)
+ __gitcomp "
+ $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
+ " "" "${cur#--*=}"
+ return
+ ;;
--*)
__gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
--compose --confirm= --dry-run --envelope-sender
diff --git a/contrib/rerere-train.sh b/contrib/rerere-train.sh
index 36b6fee..52ad9e4 100755
--- a/contrib/rerere-train.sh
+++ b/contrib/rerere-train.sh
@@ -7,7 +7,7 @@ USAGE="$me rev-list-args"
SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
-. $(git --exec-path)/git-sh-setup
+. "$(git --exec-path)/git-sh-setup"
require_work_tree
cd_to_toplevel
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 308b777..edf36f8 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -90,7 +90,7 @@ while [ $# -gt 0 ]; do
--annotate) annotate="$1"; shift ;;
--no-annotate) annotate= ;;
-b) branch="$1"; shift ;;
- -P) prefix="$1"; shift ;;
+ -P) prefix="${1%/}"; shift ;;
-m) message="$1"; shift ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
diff --git a/contrib/subtree/t/Makefile b/contrib/subtree/t/Makefile
index c864810..276898e 100644
--- a/contrib/subtree/t/Makefile
+++ b/contrib/subtree/t/Makefile
@@ -13,11 +13,23 @@ TAR ?= $(TAR)
RM ?= rm -f
PROVE ?= prove
DEFAULT_TEST_TARGET ?= test
+TEST_LINT ?= test-lint
+
+ifdef TEST_OUTPUT_DIRECTORY
+TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
+else
+TEST_RESULTS_DIRECTORY = ../../../t/test-results
+endif
# Shell quote;
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
+PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
+TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
-T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
+T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
+TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
+TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
+THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
all: $(DEFAULT_TEST_TARGET)
@@ -26,20 +38,22 @@ test: pre-clean $(TEST_LINT)
prove: pre-clean $(TEST_LINT)
@echo "*** prove ***"; GIT_CONFIG=.git/config $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
- $(MAKE) clean
+ $(MAKE) clean-except-prove-cache
$(T):
@echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
pre-clean:
- $(RM) -r test-results
+ $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
-clean:
- $(RM) -r 'trash directory'.* test-results
+clean-except-prove-cache:
+ $(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
$(RM) -r valgrind/bin
+
+clean: clean-except-prove-cache
$(RM) .prove
-test-lint: test-lint-duplicates test-lint-executable
+test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax
test-lint-duplicates:
@dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
@@ -51,12 +65,15 @@ test-lint-executable:
test -z "$$bad" || { \
echo >&2 "non-executable tests:" $$bad; exit 1; }
+test-lint-shell-syntax:
+ @'$(PERL_PATH_SQ)' ../../../t/check-non-portable-shell.pl $(T) $(THELPERS)
+
aggregate-results-and-cleanup: $(T)
$(MAKE) aggregate-results
$(MAKE) clean
aggregate-results:
- for f in ../../../t/test-results/t*-*.counts; do \
+ for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
echo "$$f"; \
done | '$(SHELL_PATH_SQ)' ../../../t/aggregate-results.sh
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index dfbe443..751aee3 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -5,7 +5,7 @@
#
test_description='Basic porcelain support for subtrees
-This test verifies the basic operation of the merge, pull, add
+This test verifies the basic operation of the add, pull, merge
and split subcommands of git subtree.
'
@@ -14,13 +14,21 @@ export TEST_DIRECTORY
. ../../../t/test-lib.sh
+subtree_test_create_repo()
+{
+ test_create_repo "$1"
+ (
+ cd $1
+ git config log.date relative
+ )
+}
+
create()
{
echo "$1" >"$1"
git add "$1"
}
-
check_equal()
{
test_debug 'echo'
@@ -38,484 +46,972 @@ undo()
git reset --hard HEAD~
}
-last_commit_message()
+# Make sure no patch changes more than one file.
+# The original set of commits changed only one file each.
+# A multi-file change would imply that we pruned commits
+# too aggressively.
+join_commits()
{
- git log --pretty=format:%s -1
+ commit=
+ all=
+ while read x y; do
+ if [ -z "$x" ]; then
+ continue
+ elif [ "$x" = "commit:" ]; then
+ if [ -n "$commit" ]; then
+ echo "$commit $all"
+ all=
+ fi
+ commit="$y"
+ else
+ all="$all $y"
+ fi
+ done
+ echo "$commit $all"
}
-test_expect_success 'init subproj' '
- test_create_repo "sub proj"
-'
-
-# To the subproject!
-cd ./"sub proj"
-
-test_expect_success 'add sub1' '
- create sub1 &&
- git commit -m "sub1" &&
- git branch sub1 &&
- git branch -m master subproj
-'
-
-# Save this hash for testing later.
-
-subdir_hash=$(git rev-parse HEAD)
-
-test_expect_success 'add sub2' '
- create sub2 &&
- git commit -m "sub2" &&
- git branch sub2
-'
-
-test_expect_success 'add sub3' '
- create sub3 &&
- git commit -m "sub3" &&
- git branch sub3
-'
-
-# Back to mainline
-cd ..
-
-test_expect_success 'enable log.date=relative to catch errors' '
- git config log.date relative
-'
-
-test_expect_success 'add main4' '
- create main4 &&
- git commit -m "main4" &&
- git branch -m master mainline &&
- git branch subdir
-'
-
-test_expect_success 'fetch subproj history' '
- git fetch ./"sub proj" sub1 &&
- git branch sub1 FETCH_HEAD
-'
-
-test_expect_success 'no subtree exists in main tree' '
- test_must_fail git subtree merge --prefix="sub dir" sub1
-'
-
-test_expect_success 'no pull from non-existant subtree' '
- test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" sub1
-'
-
-test_expect_success 'check if --message works for add' '
- git subtree add --prefix="sub dir" --message="Added subproject" sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject" &&
- undo
-'
-
-test_expect_success 'check if --message works as -m and --prefix as -P' '
- git subtree add -P "sub dir" -m "Added subproject using git subtree" sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject using git subtree" &&
- undo
-'
-
-test_expect_success 'check if --message works with squash too' '
- git subtree add -P "sub dir" -m "Added subproject with squash" --squash sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject with squash" &&
- undo
-'
-
-test_expect_success 'add subproj to mainline' '
- git subtree add --prefix="sub dir"/ FETCH_HEAD &&
- check_equal ''"$(last_commit_message)"'' "Add '"'sub dir/'"' from commit '"'"'''"$(git rev-parse sub1)"'''"'"'"
-'
-
-# this shouldn't actually do anything, since FETCH_HEAD is already a parent
-test_expect_success 'merge fetched subproj' '
- git merge -m "merge -s -ours" -s ours FETCH_HEAD
-'
-
-test_expect_success 'add main-sub5' '
- create "sub dir/main-sub5" &&
- git commit -m "main-sub5"
-'
-
-test_expect_success 'add main6' '
- create main6 &&
- git commit -m "main6 boring"
-'
-
-test_expect_success 'add main-sub7' '
- create "sub dir/main-sub7" &&
- git commit -m "main-sub7"
-'
-
-test_expect_success 'fetch new subproj history' '
- git fetch ./"sub proj" sub2 &&
- git branch sub2 FETCH_HEAD
-'
+test_create_commit() (
+ repo=$1
+ commit=$2
+ cd "$repo"
+ mkdir -p $(dirname "$commit") \
+ || error "Could not create directory for commit"
+ echo "$commit" >"$commit"
+ git add "$commit" || error "Could not add commit"
+ git commit -m "$commit" || error "Could not commit"
+)
-test_expect_success 'check if --message works for merge' '
- git subtree merge --prefix="sub dir" -m "Merged changes from subproject" sub2 &&
- check_equal ''"$(last_commit_message)"'' "Merged changes from subproject" &&
- undo
-'
+last_commit_message()
+{
+ git log --pretty=format:%s -1
+}
-test_expect_success 'check if --message for merge works with squash too' '
- git subtree merge --prefix "sub dir" -m "Merged changes from subproject using squash" --squash sub2 &&
- check_equal ''"$(last_commit_message)"'' "Merged changes from subproject using squash" &&
- undo
-'
+subtree_test_count=0
+next_test() {
+ subtree_test_count=$(($subtree_test_count+1))
+}
-test_expect_success 'merge new subproj history into subdir' '
- git subtree merge --prefix="sub dir" FETCH_HEAD &&
- git branch pre-split &&
- check_equal ''"$(last_commit_message)"'' "Merge commit '"'"'"$(git rev-parse sub2)"'"'"' into mainline" &&
- undo
-'
+#
+# Tests for 'git subtree add'
+#
-test_expect_success 'Check that prefix argument is required for split' '
- echo "You must provide the --prefix option." > expected &&
- test_must_fail git subtree split > actual 2>&1 &&
- test_debug "printf '"'"'expected: '"'"'" &&
- test_debug "cat expected" &&
- test_debug "printf '"'"'actual: '"'"'" &&
- test_debug "cat actual" &&
- test_cmp expected actual &&
- rm -f expected actual
+next_test
+test_expect_success 'no merge from non-existent subtree' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ test_must_fail git subtree merge --prefix="sub dir" FETCH_HEAD
+ )
+'
+
+next_test
+test_expect_success 'no pull from non-existent subtree' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" master
+ )'
+
+next_test
+test_expect_success 'add subproj as subtree into sub dir/ with --prefix' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD &&
+ check_equal "$(last_commit_message)" "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+next_test
+test_expect_success 'add subproj as subtree into sub dir/ with --prefix and --message' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" --message="Added subproject" FETCH_HEAD &&
+ check_equal "$(last_commit_message)" "Added subproject"
+ )
+'
+
+next_test
+test_expect_success 'add subproj as subtree into sub dir/ with --prefix as -P and --message as -m' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add -P "sub dir" -m "Added subproject" FETCH_HEAD &&
+ check_equal "$(last_commit_message)" "Added subproject"
+ )
+'
+
+next_test
+test_expect_success 'add subproj as subtree into sub dir/ with --squash and --prefix and --message' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" --message="Added subproject with squash" --squash FETCH_HEAD &&
+ check_equal "$(last_commit_message)" "Added subproject with squash"
+ )
'
-test_expect_success 'Check that the <prefix> exists for a split' '
- echo "'"'"'non-existent-directory'"'"'" does not exist\; use "'"'"'git subtree add'"'"'" > expected &&
- test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
- test_debug "printf '"'"'expected: '"'"'" &&
- test_debug "cat expected" &&
- test_debug "printf '"'"'actual: '"'"'" &&
- test_debug "cat actual" &&
- test_cmp expected actual
-# rm -f expected actual
-'
+#
+# Tests for 'git subtree merge'
+#
-test_expect_success 'check if --message works for split+rejoin' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix "sub dir" --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- git branch spl1 "$spl1" &&
- check_equal ''"$(last_commit_message)"'' "Split & rejoin" &&
- undo
+next_test
+test_expect_success 'merge new subproj history into sub dir/ with --prefix' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ check_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+next_test
+test_expect_success 'merge new subproj history into sub dir/ with --prefix and --message' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" --message="Merged changes from subproject" FETCH_HEAD &&
+ check_equal "$(last_commit_message)" "Merged changes from subproject"
+ )
+'
+
+next_test
+test_expect_success 'merge new subproj history into sub dir/ with --squash and --prefix and --message' '
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ subtree_test_create_repo "$subtree_test_count" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" --message="Merged changes from subproject using squash" --squash FETCH_HEAD &&
+ check_equal "$(last_commit_message)" "Merged changes from subproject using squash"
+ )
+'
+
+next_test
+test_expect_success 'merge the added subproj again, should do nothing' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD &&
+ # this shouldn not actually do anything, since FETCH_HEAD
+ # is already a parent
+ result=$(git merge -s ours -m "merge -s -ours" FETCH_HEAD) &&
+ check_equal "${result}" "Already up-to-date."
+ )
+'
+
+next_test
+test_expect_success 'merge new subproj history into subdir/ with a slash appended to the argument of --prefix' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir/ FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir/ FETCH_HEAD &&
+ check_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
'
-test_expect_success 'check split with --branch' '
- spl1=$(git subtree split --annotate='"'*'"' --prefix "sub dir" --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
- undo &&
- git subtree split --annotate='"'*'"' --prefix "sub dir" --onto FETCH_HEAD --branch splitbr1 &&
- check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
-'
+#
+# Tests for 'git subtree split'
+#
+next_test
+test_expect_success 'split requires option --prefix' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD &&
+ echo "You must provide the --prefix option." > expected &&
+ test_must_fail git subtree split > actual 2>&1 &&
+ test_debug "printf '"expected: "'" &&
+ test_debug "cat expected" &&
+ test_debug "printf '"actual: "'" &&
+ test_debug "cat actual" &&
+ test_cmp expected actual
+ )
+'
+
+next_test
+test_expect_success 'split requires path given by option --prefix must exist' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD &&
+ echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" > expected &&
+ test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
+ test_debug "printf '"expected: "'" &&
+ test_debug "cat expected" &&
+ test_debug "printf '"actual: "'" &&
+ test_debug "cat actual" &&
+ test_cmp expected actual
+ )
+'
+
+next_test
+test_expect_success 'split sub dir/ with --rejoin' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
+ git subtree split --prefix="sub dir" --annotate="*" --rejoin &&
+ check_equal "$(last_commit_message)" "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
+ )
+ '
+
+next_test
+test_expect_success 'split sub dir/ with --rejoin and --message' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ git subtree split --prefix="sub dir" --message="Split & rejoin" --annotate="*" --rejoin &&
+ check_equal "$(last_commit_message)" "Split & rejoin"
+ )
+'
+
+next_test
+test_expect_success 'split "sub dir"/ with --branch' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br &&
+ check_equal "$(git rev-parse subproj-br)" "$split_hash"
+ )
+'
+
+next_test
test_expect_success 'check hash of split' '
- spl1=$(git subtree split --prefix "sub dir") &&
- git subtree split --prefix "sub dir" --branch splitbr1test &&
- check_equal ''"$(git rev-parse splitbr1test)"'' "$spl1" &&
- new_hash=$(git rev-parse splitbr1test~2) &&
- check_equal ''"$new_hash"'' "$subdir_hash"
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br &&
+ check_equal "$(git rev-parse subproj-br)" "$split_hash" &&
+ # Check hash of split
+ new_hash=$(git rev-parse subproj-br^2) &&
+ (
+ cd ./"sub proj" &&
+ subdir_hash=$(git rev-parse HEAD) &&
+ check_equal ''"$new_hash"'' "$subdir_hash"
+ )
+ )
+'
+
+next_test
+test_expect_success 'split "sub dir"/ with --branch for an existing branch' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git branch subproj-br FETCH_HEAD &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br &&
+ check_equal "$(git rev-parse subproj-br)" "$split_hash"
+ )
+'
+
+next_test
+test_expect_success 'split "sub dir"/ with --branch for an incompatible branch' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git branch init HEAD &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ test_must_fail git subtree split --prefix="sub dir" --branch init
+ )
'
-test_expect_success 'check split with --branch for an existing branch' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix "sub dir" --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- undo &&
- git branch splitbr2 sub1 &&
- git subtree split --annotate='"'*'"' --prefix "sub dir" --onto FETCH_HEAD --branch splitbr2 &&
- check_equal ''"$(git rev-parse splitbr2)"'' "$spl1"
-'
-
-test_expect_success 'check split with --branch for an incompatible branch' '
- test_must_fail git subtree split --prefix "sub dir" --onto FETCH_HEAD --branch subdir
-'
-
-test_expect_success 'check split+rejoin' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix "sub dir" --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- undo &&
- git subtree split --annotate='"'*'"' --prefix "sub dir" --onto FETCH_HEAD --rejoin &&
- check_equal ''"$(last_commit_message)"'' "Split '"'"'sub dir/'"'"' into commit '"'"'"$spl1"'"'"'"
-'
-
-test_expect_success 'add main-sub8' '
- create "sub dir/main-sub8" &&
- git commit -m "main-sub8"
-'
-
-# To the subproject!
-cd ./"sub proj"
-
-test_expect_success 'merge split into subproj' '
- git fetch .. spl1 &&
- git branch spl1 FETCH_HEAD &&
- git merge FETCH_HEAD
-'
-
-test_expect_success 'add sub9' '
- create sub9 &&
- git commit -m "sub9"
-'
-
-# Back to mainline
-cd ..
-
-test_expect_success 'split for sub8' '
- split2=''"$(git subtree split --annotate='"'*'"' --prefix "sub dir/" --rejoin)"'' &&
- git branch split2 "$split2"
-'
-
-test_expect_success 'add main-sub10' '
- create "sub dir/main-sub10" &&
- git commit -m "main-sub10"
-'
-
-test_expect_success 'split for sub10' '
- spl3=''"$(git subtree split --annotate='"'*'"' --prefix "sub dir" --rejoin)"'' &&
- git branch spl3 "$spl3"
-'
-
-# To the subproject!
-cd ./"sub proj"
-
-test_expect_success 'merge split into subproj' '
- git fetch .. spl3 &&
- git branch spl3 FETCH_HEAD &&
- git merge FETCH_HEAD &&
- git branch subproj-merge-spl3
-'
+#
+# Validity checking
+#
-chkm="main4
-main6"
-chkms="main-sub10
-main-sub5
-main-sub7
-main-sub8"
-chkms_sub=$(cat <<TXT | sed 's,^,sub dir/,'
-$chkms
-TXT
-)
-chks="sub1
+next_test
+test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub3 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub3 &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD &&
+
+ chks="sub1
sub2
sub3
-sub9"
-chks_sub=$(cat <<TXT | sed 's,^,sub dir/,'
+sub4" &&
+ chks_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
$chks
TXT
-)
+) &&
+ chkms="main-sub1
+main-sub2
+main-sub3
+main-sub4" &&
+ chkms_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
+$chkms
+TXT
+) &&
-test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
- subfiles="$(git ls-files)" &&
- check_equal "$subfiles" "$chkms
+ subfiles=$(git ls-files) &&
+ check_equal "$subfiles" "$chkms
$chks"
-'
-test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '
- allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | sed "/^$/d")"'' &&
- check_equal "$allchanges" "$chkms
+ )
+'
+
+next_test
+test_expect_success 'make sure the subproj *only* contains commits that affect the "sub dir"' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub3 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub3 &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD &&
+
+ chks="sub1
+sub2
+sub3
+sub4" &&
+ chks_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
+$chks
+TXT
+) &&
+ chkms="main-sub1
+main-sub2
+main-sub3
+main-sub4" &&
+ chkms_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
+$chkms
+TXT
+) &&
+ allchanges=$(git log --name-only --pretty=format:"" | sort | sed "/^$/d") &&
+ check_equal "$allchanges" "$chkms
$chks"
+ )
'
-# Back to mainline
-cd ..
-
-test_expect_success 'pull from subproj' '
- git fetch ./"sub proj" subproj-merge-spl3 &&
- git branch subproj-merge-spl3 FETCH_HEAD &&
- git subtree pull --prefix="sub dir" ./"sub proj" subproj-merge-spl3
-'
-
+next_test
test_expect_success 'make sure exactly the right set of files ends up in the mainline' '
- mainfiles=$(git ls-files) &&
- check_equal "$mainfiles" "$chkm
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub3 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub3 &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree pull --prefix="sub dir" ./"sub proj" master &&
+
+ chkm="main1
+main2" &&
+ chks="sub1
+sub2
+sub3
+sub4" &&
+ chks_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
+$chks
+TXT
+) &&
+ chkms="main-sub1
+main-sub2
+main-sub3
+main-sub4" &&
+ chkms_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
+$chkms
+TXT
+) &&
+ mainfiles=$(git ls-files) &&
+ check_equal "$mainfiles" "$chkm
$chkms_sub
$chks_sub"
+)
'
+next_test
test_expect_success 'make sure each filename changed exactly once in the entire history' '
- # main-sub?? and /subdir/main-sub?? both change, because those are the
- # changes that were split into their own history. And subdir/sub?? never
- # change, since they were *only* changed in the subtree branch.
- allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | sed "/^$/d")"'' &&
- check_equal "$allchanges" ''"$(cat <<TXT | sort
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git config log.date relative
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub3 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub3 &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree pull --prefix="sub dir" ./"sub proj" master &&
+
+ chkm="main1
+main2" &&
+ chks="sub1
+sub2
+sub3
+sub4" &&
+ chks_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
+$chks
+TXT
+) &&
+ chkms="main-sub1
+main-sub2
+main-sub3
+main-sub4" &&
+ chkms_sub=$(cat <<TXT | sed '\''s,^,sub dir/,'\''
+$chkms
+TXT
+) &&
+
+ # main-sub?? and /"sub dir"/main-sub?? both change, because those are the
+ # changes that were split into their own history. And "sub dir"/sub?? never
+ # change, since they were *only* changed in the subtree branch.
+ allchanges=$(git log --name-only --pretty=format:"" | sort | sed "/^$/d") &&
+ expected=''"$(cat <<TXT | sort
$chkms
$chkm
$chks
$chkms_sub
TXT
-)"''
+)"'' &&
+ check_equal "$allchanges" "$expected"
+ )
'
+next_test
test_expect_success 'make sure the --rejoin commits never make it into subproj' '
- check_equal ''"$(git log --pretty=format:'"'%s'"' HEAD^2 | grep -i split)"'' ""
-'
-
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub3 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub3 &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree pull --prefix="sub dir" ./"sub proj" master &&
+ check_equal "$(git log --pretty=format:"%s" HEAD^2 | grep -i split)" ""
+ )
+'
+
+next_test
test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
- # They are meaningless to subproj since one side of the merge refers to the mainline
- check_equal ''"$(git log --pretty=format:'"'%s%n%b'"' HEAD^2 | grep "git-subtree.*:")"'' ""
-'
-
-# prepare second pair of repositories
-mkdir test2
-cd test2
-
-test_expect_success 'init main' '
- test_create_repo main
-'
-
-cd main
-
-test_expect_success 'add main1' '
- create main1 &&
- git commit -m "main1"
-'
-
-cd ..
-
-test_expect_success 'init sub' '
- test_create_repo sub
-'
-
-cd sub
-
-test_expect_success 'add sub2' '
- create sub2 &&
- git commit -m "sub2"
-'
-
-cd ../main
-
-# check if split can find proper base without --onto
-
-test_expect_success 'add sub as subdir in main' '
- git fetch ../sub master &&
- git branch sub2 FETCH_HEAD &&
- git subtree add --prefix "sub dir" sub2
-'
-
-cd ../sub
-
-test_expect_success 'add sub3' '
- create sub3 &&
- git commit -m "sub3"
-'
-
-cd ../main
-
-test_expect_success 'merge from sub' '
- git fetch ../sub master &&
- git branch sub3 FETCH_HEAD &&
- git subtree merge --prefix "sub dir" sub3
-'
-
-test_expect_success 'add main-sub4' '
- create "sub dir/main-sub4" &&
- git commit -m "main-sub4"
-'
-
-test_expect_success 'split for main-sub4 without --onto' '
- git subtree split --prefix "sub dir" --branch mainsub4
-'
-
-# at this point, the new commit parent should be sub3 if it is not,
-# something went wrong (the "newparent" of "master~" commit should
-# have been sub3, but it was not, because its cache was not set to
-# itself)
-
-test_expect_success 'check that the commit parent is sub3' '
- check_equal ''"$(git log --pretty=format:%P -1 mainsub4)"'' ''"$(git rev-parse sub3)"''
-'
-
-test_expect_success 'add main-sub5' '
- mkdir subdir2 &&
- create subdir2/main-sub5 &&
- git commit -m "main-sub5"
-'
-
-test_expect_success 'split for main-sub5 without --onto' '
- # also test that we still can split out an entirely new subtree
- # if the parent of the first commit in the tree is not empty,
- # then the new subtree has accidentally been attached to something
- git subtree split --prefix subdir2 --branch mainsub5 &&
- check_equal ''"$(git log --pretty=format:%P -1 mainsub5)"'' ""
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub3 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub3 &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub4 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$subtree_test_count/sub proj" &&
+ git fetch .. subproj-br &&
+ git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree pull --prefix="sub dir" ./"sub proj" master &&
+
+ # They are meaningless to subproj since one side of the merge refers to the mainline
+ check_equal "$(git log --pretty=format:"%s%n%b" HEAD^2 | grep "git-subtree.*:")" ""
+ )
'
-# make sure no patch changes more than one file. The original set of commits
-# changed only one file each. A multi-file change would imply that we pruned
-# commits too aggressively.
-joincommits()
-{
- commit=
- all=
- while read x y; do
- #echo "{$x}" >&2
- if [ -z "$x" ]; then
- continue
- elif [ "$x" = "commit:" ]; then
- if [ -n "$commit" ]; then
- echo "$commit $all"
- all=
- fi
- commit="$y"
- else
- all="$all $y"
- fi
- done
- echo "$commit $all"
-}
+#
+# A new set of tests
+#
+next_test
+test_expect_success 'make sure "git subtree split" find the correct parent' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git branch subproj-ref FETCH_HEAD &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --branch subproj-br &&
+
+ # at this point, the new commit parent should be subproj-ref, if it is
+ # not, something went wrong (the "newparent" of "master~" commit should
+ # have been sub2, but it was not, because its cache was not set to
+ # itself)
+ check_equal "$(git log --pretty=format:%P -1 subproj-br)" "$(git rev-parse subproj-ref)"
+ )
+'
+
+next_test
+test_expect_success 'split a new subtree without --onto option' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --branch subproj-br
+ ) &&
+ mkdir "$subtree_test_count"/"sub dir2" &&
+ test_create_commit "$subtree_test_count" "sub dir2"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+
+ # also test that we still can split out an entirely new subtree
+ # if the parent of the first commit in the tree is not empty,
+ # then the new subtree has accidently been attached to something
+ git subtree split --prefix="sub dir2" --branch subproj2-br &&
+ check_equal "$(git log --pretty=format:%P -1 subproj2-br)" ""
+ )
+'
+
+next_test
test_expect_success 'verify one file change per commit' '
- x= &&
- list=''"$(git log --pretty=format:'"'commit: %H'"' | joincommits)"'' &&
-# test_debug "echo HERE" &&
-# test_debug "echo ''"$list"''" &&
- (git log --pretty=format:'"'commit: %H'"' | joincommits |
- ( while read commit a b; do
- test_debug "echo Verifying commit "''"$commit"''
- test_debug "echo a: "''"$a"''
- test_debug "echo b: "''"$b"''
- check_equal "$b" ""
- x=1
- done
- check_equal "$x" 1
- ))
-'
-
-# test push
-
-cd ../..
-
-mkdir test-push
-
-cd test-push
-
-test_expect_success 'init main' '
- test_create_repo main
-'
-
-test_expect_success 'init sub' '
- test_create_repo "sub project"
-'
-
-cd ./"sub project"
-
-test_expect_success 'add subproject' '
- create "sub project" &&
- git commit -m "Sub project: 1" &&
- git branch sub-branch-1
-'
-
-cd ../main
-
-test_expect_success 'make first commit and add subproject' '
- create "main-1" &&
- git commit -m "main: 1" &&
- git subtree add "../sub project" --prefix "sub dir" --message "Added subproject" sub-branch-1 &&
- check_equal "$(last_commit_message)" "Added subproject"
-'
-
-test_expect_success 'make second commit to a subproject file and push it into a sub project' '
- create "sub dir/sub1" &&
- git commit -m "Sub project: 2" &&
- git subtree push "../sub project" --prefix "sub dir" sub-branch-1
-'
-
-cd ../"sub project"
-
-test_expect_success 'Test second commit is pushed' '
- git checkout sub-branch-1 &&
- check_equal "$(last_commit_message)" "Sub project: 2"
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git branch sub1 FETCH_HEAD &&
+ git subtree add --prefix="sub dir" sub1
+ ) &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir" --branch subproj-br
+ ) &&
+ mkdir "$subtree_test_count"/"sub dir2" &&
+ test_create_commit "$subtree_test_count" "sub dir2"/main-sub2 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree split --prefix="sub dir2" --branch subproj2-br &&
+
+ x= &&
+ git log --pretty=format:"commit: %H" | join_commits |
+ (
+ while read commit a b; do
+ test_debug "echo Verifying commit $commit"
+ test_debug "echo a: $a"
+ test_debug "echo b: $b"
+ check_equal "$b" ""
+ x=1
+ done
+ check_equal "$x" 1
+ )
+ )
+'
+
+next_test
+test_expect_success 'push split to subproj' '
+ subtree_test_create_repo "$subtree_test_count" &&
+ subtree_test_create_repo "$subtree_test_count/sub proj" &&
+ test_create_commit "$subtree_test_count" main1 &&
+ test_create_commit "$subtree_test_count/sub proj" sub1 &&
+ (
+ cd "$subtree_test_count" &&
+ git fetch ./"sub proj" master &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub1 &&
+ test_create_commit "$subtree_test_count" main2 &&
+ test_create_commit "$subtree_test_count/sub proj" sub2 &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub2 &&
+ (
+ cd $subtree_test_count/"sub proj" &&
+ git branch sub-branch-1 &&
+ cd .. &&
+ git fetch ./"sub proj" master &&
+ git subtree merge --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$subtree_test_count" "sub dir"/main-sub3 &&
+ (
+ cd "$subtree_test_count" &&
+ git subtree push ./"sub proj" --prefix "sub dir" sub-branch-1 &&
+ cd ./"sub proj" &&
+ git checkout sub-branch-1 &&
+ check_equal "$(last_commit_message)" "sub dir/main-sub3"
+ )
'
test_done
diff --git a/contrib/subtree/todo b/contrib/subtree/todo
index 7e44b00..0d0e777 100644
--- a/contrib/subtree/todo
+++ b/contrib/subtree/todo
@@ -12,8 +12,6 @@
exactly the right subtree structure, rather than using
subtree merge...)
- add a 'push' subcommand to parallel 'pull'
-
add a 'log' subcommand to see what's new in a subtree?
add to-submodule and from-submodule commands
diff --git a/fsck.c b/fsck.c
index e41e753..4060f1f 100644
--- a/fsck.c
+++ b/fsck.c
@@ -711,7 +711,8 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,
}
}
- if (verify_headers(buffer, size, &tag->object, options))
+ ret = verify_headers(buffer, size, &tag->object, options);
+ if (ret)
goto done;
if (!skip_prefix(buffer, "object ", &buffer)) {
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 27c9c54..98f1779 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -306,6 +306,15 @@ then
start_timestamp=$(date '+%s')
fi
+if test -n "$filter_index" ||
+ test -n "$filter_tree" ||
+ test -n "$filter_subdir"
+then
+ need_index=t
+else
+ need_index=
+fi
+
while read commit parents; do
git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))
@@ -313,7 +322,10 @@ while read commit parents; do
case "$filter_subdir" in
"")
- GIT_ALLOW_NULL_SHA1=1 git read-tree -i -m $commit
+ if test -n "$need_index"
+ then
+ GIT_ALLOW_NULL_SHA1=1 git read-tree -i -m $commit
+ fi
;;
*)
# The commit may not have the subdirectory at all
@@ -349,7 +361,7 @@ while read commit parents; do
die "tree filter failed: $filter_tree"
(
- git diff-index -r --name-only --ignore-submodules $commit &&
+ git diff-index -r --name-only --ignore-submodules $commit -- &&
git ls-files --others
) > "$tempdir"/tree-state || exit
git update-index --add --replace --remove --stdin \
@@ -387,8 +399,15 @@ while read commit parents; do
} <../commit |
eval "$filter_msg" > ../message ||
die "msg filter failed: $filter_msg"
+
+ if test -n "$need_index"
+ then
+ tree=$(git write-tree)
+ else
+ tree="$commit^{tree}"
+ fi
workdir=$workdir @SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
- $(git write-tree) $parentstr < ../message > ../map/$commit ||
+ "$tree" $parentstr < ../message > ../map/$commit ||
die "could not write rewritten commit"
done <../revs
diff --git a/git-p4.py b/git-p4.py
index 212ef2b..13f1240 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -203,14 +203,16 @@ def p4_has_move_command():
# assume it failed because @... was invalid changelist
return True
-def system(cmd):
+def system(cmd, ignore_error=False):
expand = isinstance(cmd,basestring)
if verbose:
sys.stderr.write("executing %s\n" % str(cmd))
retcode = subprocess.call(cmd, shell=expand)
- if retcode:
+ if retcode and not ignore_error:
raise CalledProcessError(retcode, cmd)
+ return retcode
+
def p4_system(cmd):
"""Specifically invoke p4 as the system command. """
real_cmd = p4_build_cmd(cmd)
@@ -553,7 +555,12 @@ def p4Where(depotPath):
return clientPath
def currentGitBranch():
- return read_pipe("git name-rev HEAD").split(" ")[1].strip()
+ retcode = system(["git", "symbolic-ref", "-q", "HEAD"], ignore_error=True)
+ if retcode != 0:
+ # on a detached head
+ return None
+ else:
+ return read_pipe(["git", "name-rev", "HEAD"]).split(" ")[1].strip()
def isValidGitDir(path):
if (os.path.exists(path + "/HEAD")
@@ -1741,44 +1748,47 @@ class P4Submit(Command, P4UserMap):
#
# Let the user edit the change description, then submit it.
#
- if self.edit_template(fileName):
- # read the edited message and submit
- ret = True
- tmpFile = open(fileName, "rb")
- message = tmpFile.read()
- tmpFile.close()
- if self.isWindows:
- message = message.replace("\r\n", "\n")
- submitTemplate = message[:message.index(separatorLine)]
- p4_write_pipe(['submit', '-i'], submitTemplate)
-
- if self.preserveUser:
- if p4User:
- # Get last changelist number. Cannot easily get it from
- # the submit command output as the output is
- # unmarshalled.
- changelist = self.lastP4Changelist()
- self.modifyChangelistUser(changelist, p4User)
-
- # The rename/copy happened by applying a patch that created a
- # new file. This leaves it writable, which confuses p4.
- for f in pureRenameCopy:
- p4_sync(f, "-f")
+ submitted = False
- else:
+ try:
+ if self.edit_template(fileName):
+ # read the edited message and submit
+ tmpFile = open(fileName, "rb")
+ message = tmpFile.read()
+ tmpFile.close()
+ if self.isWindows:
+ message = message.replace("\r\n", "\n")
+ submitTemplate = message[:message.index(separatorLine)]
+ p4_write_pipe(['submit', '-i'], submitTemplate)
+
+ if self.preserveUser:
+ if p4User:
+ # Get last changelist number. Cannot easily get it from
+ # the submit command output as the output is
+ # unmarshalled.
+ changelist = self.lastP4Changelist()
+ self.modifyChangelistUser(changelist, p4User)
+
+ # The rename/copy happened by applying a patch that created a
+ # new file. This leaves it writable, which confuses p4.
+ for f in pureRenameCopy:
+ p4_sync(f, "-f")
+ submitted = True
+
+ finally:
# skip this patch
- ret = False
- print "Submission cancelled, undoing p4 changes."
- for f in editedFiles:
- p4_revert(f)
- for f in filesToAdd:
- p4_revert(f)
- os.remove(f)
- for f in filesToDelete:
- p4_revert(f)
+ if not submitted:
+ print "Submission cancelled, undoing p4 changes."
+ for f in editedFiles:
+ p4_revert(f)
+ for f in filesToAdd:
+ p4_revert(f)
+ os.remove(f)
+ for f in filesToDelete:
+ p4_revert(f)
os.remove(fileName)
- return ret
+ return submitted
# Export git tags as p4 labels. Create a p4 label and then tag
# with that.
@@ -1854,8 +1864,6 @@ class P4Submit(Command, P4UserMap):
def run(self, args):
if len(args) == 0:
self.master = currentGitBranch()
- if len(self.master) == 0 or not gitBranchExists("refs/heads/%s" % self.master):
- die("Detecting current git branch failed!")
elif len(args) == 1:
self.master = args[0]
if not branchExists(self.master):
@@ -1863,9 +1871,10 @@ class P4Submit(Command, P4UserMap):
else:
return False
- allowSubmit = gitConfig("git-p4.allowSubmit")
- if len(allowSubmit) > 0 and not self.master in allowSubmit.split(","):
- die("%s is not in git-p4.allowSubmit" % self.master)
+ if self.master:
+ allowSubmit = gitConfig("git-p4.allowSubmit")
+ if len(allowSubmit) > 0 and not self.master in allowSubmit.split(","):
+ die("%s is not in git-p4.allowSubmit" % self.master)
[upstream, settings] = findUpstreamBranchPoint()
self.depotPath = settings['depot-paths'][0]
@@ -1933,7 +1942,12 @@ class P4Submit(Command, P4UserMap):
self.check()
commits = []
- for line in read_pipe_lines(["git", "rev-list", "--no-merges", "%s..%s" % (self.origin, self.master)]):
+ if self.master:
+ commitish = self.master
+ else:
+ commitish = 'HEAD'
+
+ for line in read_pipe_lines(["git", "rev-list", "--no-merges", "%s..%s" % (self.origin, commitish)]):
commits.append(line.strip())
commits.reverse()
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 30edb17..b938a6d 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -610,7 +610,7 @@ do_next () {
read -r command rest < "$todo"
mark_action_done
printf 'Executing: %s\n' "$rest"
- ${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution
+ "${SHELL:-@SHELL_PATH@}" -c "$rest" # Actual execution
status=$?
# Run in subshell because require_clean_work_tree can die.
dirty=f
diff --git a/git-send-email.perl b/git-send-email.perl
index e907e0e..2a3873b 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -46,6 +46,7 @@ package main;
sub usage {
print <<EOT;
git send-email [options] <file | directory | rev-list options >
+git send-email --dump-aliases
Composing:
--from <str> * Email From:
@@ -101,6 +102,9 @@ git send-email [options] <file | directory | rev-list options >
`git format-patch` ones.
--force * Send even if safety checks would prevent it.
+ Information:
+ --dump-aliases * Dump configured aliases and exit.
+
EOT
exit(1);
}
@@ -180,6 +184,7 @@ my ($quiet, $dry_run) = (0, 0);
my $format_patch;
my $compose_filename;
my $force = 0;
+my $dump_aliases = 0;
# Handle interactive edition of files.
my $multiedit;
@@ -239,7 +244,6 @@ my %config_settings = (
"smtpserveroption" => \@smtp_server_options,
"smtpuser" => \$smtp_authuser,
"smtppass" => \$smtp_authpass,
- "smtpsslcertpath" => \$smtp_ssl_cert_path,
"smtpdomain" => \$smtp_domain,
"smtpauth" => \$smtp_auth,
"to" => \@initial_to,
@@ -259,6 +263,7 @@ my %config_settings = (
my %config_path_settings = (
"aliasesfile" => \@alias_files,
+ "smtpsslcertpath" => \$smtp_ssl_cert_path,
);
# Handle Uncouth Termination
@@ -291,6 +296,11 @@ $SIG{INT} = \&signal_handler;
my $help;
my $rc = GetOptions("h" => \$help,
+ "dump-aliases" => \$dump_aliases);
+usage() unless $rc;
+die "--dump-aliases incompatible with other options\n"
+ if !$help and $dump_aliases and @ARGV;
+$rc = GetOptions(
"sender|from=s" => \$sender,
"in-reply-to=s" => \$initial_reply_to,
"subject=s" => \$initial_subject,
@@ -551,6 +561,11 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
}
}
+if ($dump_aliases) {
+ print "$_\n" for (sort keys %aliases);
+ exit(0);
+}
+
# is_format_patch_arg($f) returns 0 if $f names a patch, or 1 if
# $f is a revision list specification to be passed to format-patch.
sub is_format_patch_arg {
@@ -1196,8 +1211,7 @@ sub ssl_verify_params {
return (SSL_verify_mode => SSL_VERIFY_PEER(),
SSL_ca_file => $smtp_ssl_cert_path);
} else {
- print STDERR "Not using SSL_VERIFY_PEER because the CA path does not exist.\n";
- return (SSL_verify_mode => SSL_VERIFY_NONE());
+ die "CA path \"$smtp_ssl_cert_path\" does not exist";
}
}
diff --git a/http.c b/http.c
index 42f29ce..7d4cb2d 100644
--- a/http.c
+++ b/http.c
@@ -214,10 +214,10 @@ static int http_options(const char *var, const char *value, void *cb)
#endif
#if LIBCURL_VERSION_NUM >= 0x070908
if (!strcmp("http.sslcapath", var))
- return git_config_string(&ssl_capath, var, value);
+ return git_config_pathname(&ssl_capath, var, value);
#endif
if (!strcmp("http.sslcainfo", var))
- return git_config_string(&ssl_cainfo, var, value);
+ return git_config_pathname(&ssl_cainfo, var, value);
if (!strcmp("http.sslcertpasswordprotected", var)) {
ssl_cert_password_required = git_config_bool(var, value);
return 0;
@@ -464,6 +464,17 @@ static CURL *get_curl_handle(void)
if (curl_http_proxy) {
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
+#if LIBCURL_VERSION_NUM >= 0x071800
+ if (starts_with(curl_http_proxy, "socks5"))
+ curl_easy_setopt(result,
+ CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ else if (starts_with(curl_http_proxy, "socks4a"))
+ curl_easy_setopt(result,
+ CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
+ else if (starts_with(curl_http_proxy, "socks"))
+ curl_easy_setopt(result,
+ CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+#endif
}
#if LIBCURL_VERSION_NUM >= 0x070a07
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
@@ -1617,8 +1628,8 @@ struct http_pack_request *new_http_pack_request(
if (prev_posn>0) {
if (http_is_verbose)
fprintf(stderr,
- "Resuming fetch of pack %s at byte %ld\n",
- sha1_to_hex(target->sha1), prev_posn);
+ "Resuming fetch of pack %s at byte %"PRIuMAX"\n",
+ sha1_to_hex(target->sha1), (uintmax_t)prev_posn);
http_opt_request_remainder(preq->slot->curl, prev_posn);
}
@@ -1772,8 +1783,8 @@ struct http_object_request *new_http_object_request(const char *base_url,
if (prev_posn>0) {
if (http_is_verbose)
fprintf(stderr,
- "Resuming fetch of object %s at byte %ld\n",
- hex, prev_posn);
+ "Resuming fetch of object %s at byte %"PRIuMAX"\n",
+ hex, (uintmax_t)prev_posn);
http_opt_request_remainder(freq->slot->curl, prev_posn);
}
diff --git a/parse-options.c b/parse-options.c
index 3eceba4..47a9192 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -5,10 +5,6 @@
#include "color.h"
#include "utf8.h"
-static int parse_options_usage(struct parse_opt_ctx_t *ctx,
- const char * const *usagestr,
- const struct option *opts, int err);
-
#define OPT_SHORT 1
#define OPT_UNSET 2
@@ -414,7 +410,7 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,
const struct option *options, int flags)
{
memset(ctx, 0, sizeof(*ctx));
- ctx->argc = argc - 1;
+ ctx->argc = ctx->total = argc - 1;
ctx->argv = argv + 1;
ctx->out = argv;
ctx->prefix = prefix;
@@ -435,6 +431,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
const char * const usagestr[])
{
int internal_help = !(ctx->flags & PARSE_OPT_NO_INTERNAL_HELP);
+ int err = 0;
/* we must reset ->opt, unknown short option leave it dangling */
ctx->opt = NULL;
@@ -451,27 +448,32 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
continue;
}
+ /* lone -h asks for help */
+ if (internal_help && ctx->total == 1 && !strcmp(arg + 1, "h"))
+ goto show_usage;
+
if (arg[1] != '-') {
ctx->opt = arg + 1;
- if (internal_help && *ctx->opt == 'h')
- return parse_options_usage(ctx, usagestr, options, 0);
switch (parse_short_opt(ctx, options)) {
case -1:
- return parse_options_usage(ctx, usagestr, options, 1);
+ goto show_usage_error;
case -2:
if (ctx->opt)
check_typos(arg + 1, options);
+ if (internal_help && *ctx->opt == 'h')
+ goto show_usage;
goto unknown;
}
if (ctx->opt)
check_typos(arg + 1, options);
while (ctx->opt) {
- if (internal_help && *ctx->opt == 'h')
- return parse_options_usage(ctx, usagestr, options, 0);
switch (parse_short_opt(ctx, options)) {
case -1:
- return parse_options_usage(ctx, usagestr, options, 1);
+ goto show_usage_error;
case -2:
+ if (internal_help && *ctx->opt == 'h')
+ goto show_usage;
+
/* fake a short option thing to hide the fact that we may have
* started to parse aggregated stuff
*
@@ -496,10 +498,10 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
if (internal_help && !strcmp(arg + 2, "help-all"))
return usage_with_options_internal(ctx, usagestr, options, 1, 0);
if (internal_help && !strcmp(arg + 2, "help"))
- return parse_options_usage(ctx, usagestr, options, 0);
+ goto show_usage;
switch (parse_long_opt(ctx, arg + 2, options)) {
case -1:
- return parse_options_usage(ctx, usagestr, options, 1);
+ goto show_usage_error;
case -2:
goto unknown;
}
@@ -511,6 +513,11 @@ unknown:
ctx->opt = NULL;
}
return PARSE_OPT_DONE;
+
+ show_usage_error:
+ err = 1;
+ show_usage:
+ return usage_with_options_internal(ctx, usagestr, options, 0, err);
}
int parse_options_end(struct parse_opt_ctx_t *ctx)
@@ -656,13 +663,6 @@ void NORETURN usage_msg_opt(const char *msg,
usage_with_options(usagestr, options);
}
-static int parse_options_usage(struct parse_opt_ctx_t *ctx,
- const char * const *usagestr,
- const struct option *opts, int err)
-{
- return usage_with_options_internal(ctx, usagestr, opts, 0, err);
-}
-
#undef opterror
int opterror(const struct option *opt, const char *reason, int flags)
{
diff --git a/parse-options.h b/parse-options.h
index e8b55ea..ea4af92 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -199,7 +199,7 @@ enum {
struct parse_opt_ctx_t {
const char **argv;
const char **out;
- int argc, cpidx;
+ int argc, cpidx, total;
const char *opt;
int flags;
const char *prefix;
diff --git a/ppc/sha1.h b/ppc/sha1.h
index c405f73..9b24b32 100644
--- a/ppc/sha1.h
+++ b/ppc/sha1.h
@@ -19,7 +19,7 @@ int ppc_SHA1_Init(ppc_SHA_CTX *c);
int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *p, unsigned long n);
int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c);
-#define git_SHA_CTX ppc_SHA_CTX
-#define git_SHA1_Init ppc_SHA1_Init
-#define git_SHA1_Update ppc_SHA1_Update
-#define git_SHA1_Final ppc_SHA1_Final
+#define platform_SHA_CTX ppc_SHA_CTX
+#define platform_SHA1_Init ppc_SHA1_Init
+#define platform_SHA1_Update ppc_SHA1_Update
+#define platform_SHA1_Final ppc_SHA1_Final
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index b1673b3..093832f 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -68,6 +68,13 @@ test_expect_success 'blame 1 author' '
check_count A 2
'
+test_expect_success 'blame by tag objects' '
+ git tag -m "test tag" testTag &&
+ git tag -m "test tag #2" testTag2 testTag &&
+ check_count -h testTag A 2 &&
+ check_count -h testTag2 A 2
+'
+
test_expect_success 'setup B lines' '
echo "2A quick brown fox jumps over the" >>file &&
echo "lazy dog" >>file &&
diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh
index 7548225..f9ae1d7 100644
--- a/t/lib-git-p4.sh
+++ b/t/lib-git-p4.sh
@@ -6,6 +6,14 @@
# a subdirectory called "$git"
TEST_NO_CREATE_REPO=NoThanks
+# Some operations require multiple attempts to be successful. Define
+# here the maximal retry timeout in seconds.
+RETRY_TIMEOUT=60
+
+# Sometimes p4d seems to hang. Terminate the p4d process automatically after
+# the defined timeout in seconds.
+P4D_TIMEOUT=300
+
. ./test-lib.sh
if ! test_have_prereq PYTHON
@@ -36,6 +44,15 @@ native_path() {
echo "$path"
}
+# On Solaris the 'date +%s' function is not supported and therefore we
+# need this replacement.
+# Attention: This function is not safe again against time offset updates
+# at runtime (e.g. via NTP). The 'clock_gettime(CLOCK_MONOTONIC)'
+# function could fix that but it is not in Python until 3.3.
+time_in_seconds() {
+ python -c 'import time; print int(time.time())'
+}
+
# Try to pick a unique port: guess a large number, then hope
# no more than one of each test is running.
#
@@ -57,6 +74,15 @@ cli="$TRASH_DIRECTORY/cli"
git="$TRASH_DIRECTORY/git"
pidfile="$TRASH_DIRECTORY/p4d.pid"
+# Sometimes "prove" seems to hang on exit because p4d is still running
+cleanup() {
+ if test -f "$pidfile"
+ then
+ kill -9 $(cat "$pidfile") 2>/dev/null && exit 255
+ fi
+}
+trap cleanup EXIT
+
# git p4 submit generates a temp file, which will
# not get cleaned up if the submission fails. Don't
# clutter up /tmp on the test machine.
@@ -81,6 +107,19 @@ start_p4d() {
# will be caught with the "kill -0" check below.
i=${P4D_START_PATIENCE:-300}
pid=$(cat "$pidfile")
+
+ timeout=$(($(time_in_seconds) + $P4D_TIMEOUT))
+ while true
+ do
+ if test $(time_in_seconds) -gt $timeout
+ then
+ kill -9 $pid
+ exit 1
+ fi
+ sleep 1
+ done &
+ watchdog_pid=$!
+
ready=
while test $i -gt 0
do
@@ -121,22 +160,36 @@ p4_add_user() {
EOF
}
+retry_until_success() {
+ timeout=$(($(time_in_seconds) + $RETRY_TIMEOUT))
+ until "$@" 2>/dev/null || test $(time_in_seconds) -gt $timeout
+ do
+ sleep 1
+ done
+}
+
+retry_until_fail() {
+ timeout=$(($(time_in_seconds) + $RETRY_TIMEOUT))
+ until ! "$@" 2>/dev/null || test $(time_in_seconds) -gt $timeout
+ do
+ sleep 1
+ done
+}
+
kill_p4d() {
pid=$(cat "$pidfile")
- # it had better exist for the first kill
- kill $pid &&
- for i in 1 2 3 4 5 ; do
- kill $pid >/dev/null 2>&1 || break
- sleep 1
- done &&
+ retry_until_fail kill $pid
+ retry_until_fail kill -9 $pid
# complain if it would not die
test_must_fail kill $pid >/dev/null 2>&1 &&
- rm -rf "$db" "$cli" "$pidfile"
+ rm -rf "$db" "$cli" "$pidfile" &&
+ retry_until_fail kill -9 $watchdog_pid
}
cleanup_git() {
- rm -rf "$git" &&
- mkdir "$git"
+ retry_until_success rm -r "$git"
+ test_must_fail test -d "$git" &&
+ retry_until_success mkdir "$git"
}
marshal_dump() {
diff --git a/t/perf/p7000-filter-branch.sh b/t/perf/p7000-filter-branch.sh
new file mode 100755
index 0000000..15ee5d1
--- /dev/null
+++ b/t/perf/p7000-filter-branch.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+test_description='performance of filter-branch'
+. ./perf-lib.sh
+
+test_perf_default_repo
+test_checkout_worktree
+
+test_expect_success 'mark bases for tests' '
+ git tag -f tip &&
+ git tag -f base HEAD~100
+'
+
+test_perf 'noop filter' '
+ git checkout --detach tip &&
+ git filter-branch -f base..HEAD
+'
+
+test_done
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index dc09797..e66b7cb 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -176,6 +176,18 @@ test_expect_success 'integer overflow in timestamps is reported' '
grep "error in commit $new.*integer overflow" out
'
+test_expect_success 'commit with NUL in header' '
+ git cat-file commit HEAD >basis &&
+ sed "s/author ./author Q/" <basis | q_to_nul >commit-NUL-header &&
+ new=$(git hash-object -t commit -w --stdin <commit-NUL-header) &&
+ test_when_finished "remove_object $new" &&
+ git update-ref refs/heads/bogus "$new" &&
+ test_when_finished "git update-ref -d refs/heads/bogus" &&
+ test_must_fail git fsck 2>out &&
+ cat out &&
+ grep "error in commit $new.*unterminated header: NUL at offset" out
+'
+
test_expect_success 'malformatted tree object' '
test_when_finished "git update-ref -d refs/tags/wrong" &&
test_when_finished "remove_object \$T" &&
@@ -276,6 +288,26 @@ test_expect_success 'tag with bad tagger' '
grep "error in tag .*: invalid author/committer" out
'
+test_expect_success 'tag with NUL in header' '
+ sha=$(git rev-parse HEAD) &&
+ q_to_nul >tag-NUL-header <<-EOF &&
+ object $sha
+ type commit
+ tag contains-Q-in-header
+ tagger T A Gger <tagger@example.com> 1234567890 -0000
+
+ This is an invalid tag.
+ EOF
+
+ tag=$(git hash-object --literally -t tag -w --stdin <tag-NUL-header) &&
+ test_when_finished "remove_object $tag" &&
+ echo $tag >.git/refs/tags/wrong &&
+ test_when_finished "git update-ref -d refs/tags/wrong" &&
+ test_must_fail git fsck --tags 2>out &&
+ cat out &&
+ grep "error in tag $tag.*unterminated header: NUL at offset" out
+'
+
test_expect_success 'cleaned up' '
git fsck >actual 2>&1 &&
test_cmp empty actual
diff --git a/t/t5571-pre-push-hook.sh b/t/t5571-pre-push-hook.sh
index 6f9916a..ba975bb 100755
--- a/t/t5571-pre-push-hook.sh
+++ b/t/t5571-pre-push-hook.sh
@@ -109,23 +109,20 @@ test_expect_success 'push to URL' '
diff expected actual
'
-# Test that filling pipe buffers doesn't cause failure
-# Too slow to leave enabled for general use
-if false
-then
- printf 'parent1\nrepo1\n' >expected
- nr=1000
- while test $nr -lt 2000
- do
- nr=$(( $nr + 1 ))
- git branch b/$nr $COMMIT3
- echo "refs/heads/b/$nr $COMMIT3 refs/heads/b/$nr $_z40" >>expected
- done
-
- test_expect_success 'push many refs' '
- git push parent1 "refs/heads/b/*:refs/heads/b/*" &&
- diff expected actual
- '
-fi
+test_expect_success 'set up many-ref tests' '
+ {
+ nr=1000
+ while test $nr -lt 2000
+ do
+ nr=$(( $nr + 1 ))
+ echo "create refs/heads/b/$nr $COMMIT3"
+ done
+ } | git update-ref --stdin
+'
+
+test_expect_success 'sigpipe does not cause pre-push hook failure' '
+ echo "exit 0" | write_script "$HOOK" &&
+ git push parent1 "refs/heads/b/*:refs/heads/b/*"
+'
test_done
diff --git a/t/t5813-proto-disable-ssh.sh b/t/t5813-proto-disable-ssh.sh
index ad877d7..a954ead 100755
--- a/t/t5813-proto-disable-ssh.sh
+++ b/t/t5813-proto-disable-ssh.sh
@@ -14,7 +14,7 @@ test_expect_success 'setup repository to clone' '
'
test_proto "host:path" ssh "remote:repo.git"
-test_proto "ssh://" ssh "ssh://remote/$PWD/remote/repo.git"
-test_proto "git+ssh://" ssh "git+ssh://remote/$PWD/remote/repo.git"
+test_proto "ssh://" ssh "ssh://remote$PWD/remote/repo.git"
+test_proto "git+ssh://" ssh "git+ssh://remote$PWD/remote/repo.git"
test_done
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 377c648..869e0bf 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -418,4 +418,11 @@ test_expect_success 'filter commit message without trailing newline' '
test_cmp expect actual
'
+test_expect_success 'tree-filter deals with object name vs pathname ambiguity' '
+ test_when_finished "git reset --hard original" &&
+ ambiguous=$(git rev-list -1 HEAD) &&
+ git filter-branch --tree-filter "mv file.t $ambiguous" HEAD^.. &&
+ git show HEAD:$ambiguous
+'
+
test_done
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 5b4a5ce..3c49536 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1555,6 +1555,88 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
grep "^!someone@example\.org!$" commandline1
'
+test_dump_aliases () {
+ msg="$1" && shift &&
+ filetype="$1" && shift &&
+ printf '%s\n' "$@" >expect &&
+ cat >.tmp-email-aliases &&
+
+ test_expect_success $PREREQ "$msg" '
+ clean_fake_sendmail && rm -fr outdir &&
+ git config --replace-all sendemail.aliasesfile \
+ "$(pwd)/.tmp-email-aliases" &&
+ git config sendemail.aliasfiletype "$filetype" &&
+ git send-email --dump-aliases 2>errors >actual &&
+ test_cmp expect actual
+ '
+}
+
+test_dump_aliases '--dump-aliases sendmail format' \
+ 'sendmail' \
+ 'abgroup' \
+ 'alice' \
+ 'bcgrp' \
+ 'bob' \
+ 'chloe' <<-\EOF
+ alice: Alice W Land <awol@example.com>
+ bob: Robert Bobbyton <bob@example.com>
+ chloe: chloe@example.com
+ abgroup: alice, bob
+ bcgrp: bob, chloe, Other <o@example.com>
+ EOF
+
+test_dump_aliases '--dump-aliases mutt format' \
+ 'mutt' \
+ 'alice' \
+ 'bob' \
+ 'chloe' \
+ 'donald' <<-\EOF
+ alias alice Alice W Land <awol@example.com>
+ alias donald Donald C Carlton <donc@example.com>
+ alias bob Robert Bobbyton <bob@example.com>
+ alias chloe chloe@example.com
+ EOF
+
+test_dump_aliases '--dump-aliases mailrc format' \
+ 'mailrc' \
+ 'alice' \
+ 'bob' \
+ 'chloe' \
+ 'eve' <<-\EOF
+ alias alice Alice W Land <awol@example.com>
+ alias eve Eve <eve@example.com>
+ alias bob Robert Bobbyton <bob@example.com>
+ alias chloe chloe@example.com
+ EOF
+
+test_dump_aliases '--dump-aliases pine format' \
+ 'pine' \
+ 'alice' \
+ 'bob' \
+ 'chloe' \
+ 'eve' <<-\EOF
+ alice Alice W Land <awol@example.com>
+ eve Eve <eve@example.com>
+ bob Robert Bobbyton <bob@example.com>
+ chloe chloe@example.com
+ EOF
+
+test_dump_aliases '--dump-aliases gnus format' \
+ 'gnus' \
+ 'alice' \
+ 'bob' \
+ 'chloe' \
+ 'eve' <<-\EOF
+ (define-mail-alias "alice" "awol@example.com")
+ (define-mail-alias "eve" "eve@example.com")
+ (define-mail-alias "bob" "bob@example.com")
+ (define-mail-alias "chloe" "chloe@example.com")
+ EOF
+
+test_expect_success '--dump-aliases must be used alone' '
+ test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting
+'
+
test_sendmail_aliases () {
msg="$1" && shift &&
expect="$@" &&
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 9984c48..14a9384 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -47,1077 +47,1075 @@ file5_data='an inline file.
file6_data='#!/bin/sh
echo "$@"'
->empty
-
###
### series A
###
-test_tick
-
test_expect_success 'empty stream succeeds' '
git fast-import </dev/null
'
-cat >input <<INPUT_END
-blob
-mark :2
-data <<EOF
-$file2_data
-EOF
-
-blob
-mark :3
-data <<END
-$file3_data
-END
-
-blob
-mark :4
-data $file4_len
-$file4_data
-commit refs/heads/master
-mark :5
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-initial
-COMMIT
-
-M 644 :2 file2
-M 644 :3 file3
-M 755 :4 file4
-
-tag series-A
-from :5
-data <<EOF
-An annotated tag without a tagger
-EOF
-
-tag series-A-blob
-from :3
-data <<EOF
-An annotated tag that annotates a blob.
-EOF
-
-INPUT_END
-test_expect_success \
- 'A: create pack from stdin' \
- 'git fast-import --export-marks=marks.out <input &&
- git whatchanged master'
+test_expect_success 'A: create pack from stdin' '
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ blob
+ mark :2
+ data <<EOF
+ $file2_data
+ EOF
+
+ blob
+ mark :3
+ data <<END
+ $file3_data
+ END
+
+ blob
+ mark :4
+ data $file4_len
+ $file4_data
+ commit refs/heads/master
+ mark :5
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ initial
+ COMMIT
+
+ M 644 :2 file2
+ M 644 :3 file3
+ M 755 :4 file4
+
+ tag series-A
+ from :5
+ data <<EOF
+ An annotated tag without a tagger
+ EOF
+
+ tag series-A-blob
+ from :3
+ data <<EOF
+ An annotated tag that annotates a blob.
+ EOF
+
+ INPUT_END
+ git fast-import --export-marks=marks.out <input &&
+ git whatchanged master
+'
test_expect_success 'A: verify pack' '
verify_packs
'
-cat >expect <<EOF
-author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-
-initial
-EOF
-test_expect_success \
- 'A: verify commit' \
- 'git cat-file commit master | sed 1d >actual &&
- test_cmp expect actual'
-
-cat >expect <<EOF
-100644 blob file2
-100644 blob file3
-100755 blob file4
-EOF
-test_expect_success \
- 'A: verify tree' \
- 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
- test_cmp expect actual'
-
-echo "$file2_data" >expect
-test_expect_success \
- 'A: verify file2' \
- 'git cat-file blob master:file2 >actual && test_cmp expect actual'
-
-echo "$file3_data" >expect
-test_expect_success \
- 'A: verify file3' \
- 'git cat-file blob master:file3 >actual && test_cmp expect actual'
-
-printf "$file4_data" >expect
-test_expect_success \
- 'A: verify file4' \
- 'git cat-file blob master:file4 >actual && test_cmp expect actual'
-
-cat >expect <<EOF
-object $(git rev-parse refs/heads/master)
-type commit
-tag series-A
-
-An annotated tag without a tagger
-EOF
+test_expect_success 'A: verify commit' '
+ cat >expect <<-EOF &&
+ author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+ initial
+ EOF
+ git cat-file commit master | sed 1d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'A: verify tree' '
+ cat >expect <<-EOF &&
+ 100644 blob file2
+ 100644 blob file3
+ 100755 blob file4
+ EOF
+ git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'A: verify file2' '
+ echo "$file2_data" >expect &&
+ git cat-file blob master:file2 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'A: verify file3' '
+ echo "$file3_data" >expect &&
+ git cat-file blob master:file3 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'A: verify file4' '
+ printf "$file4_data" >expect &&
+ git cat-file blob master:file4 >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'A: verify tag/series-A' '
+ cat >expect <<-EOF &&
+ object $(git rev-parse refs/heads/master)
+ type commit
+ tag series-A
+
+ An annotated tag without a tagger
+ EOF
git cat-file tag tags/series-A >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-object $(git rev-parse refs/heads/master:file3)
-type blob
-tag series-A-blob
-
-An annotated tag that annotates a blob.
-EOF
test_expect_success 'A: verify tag/series-A-blob' '
+ cat >expect <<-EOF &&
+ object $(git rev-parse refs/heads/master:file3)
+ type blob
+ tag series-A-blob
+
+ An annotated tag that annotates a blob.
+ EOF
git cat-file tag tags/series-A-blob >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-:2 `git rev-parse --verify master:file2`
-:3 `git rev-parse --verify master:file3`
-:4 `git rev-parse --verify master:file4`
-:5 `git rev-parse --verify master^0`
-EOF
-test_expect_success \
- 'A: verify marks output' \
- 'test_cmp expect marks.out'
+test_expect_success 'A: verify marks output' '
+ cat >expect <<-EOF &&
+ :2 `git rev-parse --verify master:file2`
+ :3 `git rev-parse --verify master:file3`
+ :4 `git rev-parse --verify master:file4`
+ :5 `git rev-parse --verify master^0`
+ EOF
+ test_cmp expect marks.out
+'
-test_expect_success \
- 'A: verify marks import' \
- 'git fast-import \
+test_expect_success 'A: verify marks import' '
+ git fast-import \
--import-marks=marks.out \
--export-marks=marks.new \
</dev/null &&
- test_cmp expect marks.new'
-
-test_tick
-new_blob=$(echo testing | git hash-object --stdin)
-cat >input <<INPUT_END
-tag series-A-blob-2
-from $(git rev-parse refs/heads/master:file3)
-data <<EOF
-Tag blob by sha1.
-EOF
-
-blob
-mark :6
-data <<EOF
-testing
-EOF
-
-commit refs/heads/new_blob
-committer <> 0 +0000
-data 0
-M 644 :6 new_blob
-#pretend we got sha1 from fast-import
-ls "new_blob"
-
-tag series-A-blob-3
-from $new_blob
-data <<EOF
-Tag new_blob.
-EOF
-INPUT_END
-
-cat >expect <<EOF
-object $(git rev-parse refs/heads/master:file3)
-type blob
-tag series-A-blob-2
-
-Tag blob by sha1.
-object $new_blob
-type blob
-tag series-A-blob-3
-
-Tag new_blob.
-EOF
-
-test_expect_success \
- 'A: tag blob by sha1' \
- 'git fast-import <input &&
+ test_cmp expect marks.new
+'
+
+test_expect_success 'A: tag blob by sha1' '
+ test_tick &&
+ new_blob=$(echo testing | git hash-object --stdin) &&
+ cat >input <<-INPUT_END &&
+ tag series-A-blob-2
+ from $(git rev-parse refs/heads/master:file3)
+ data <<EOF
+ Tag blob by sha1.
+ EOF
+
+ blob
+ mark :6
+ data <<EOF
+ testing
+ EOF
+
+ commit refs/heads/new_blob
+ committer <> 0 +0000
+ data 0
+ M 644 :6 new_blob
+ #pretend we got sha1 from fast-import
+ ls "new_blob"
+
+ tag series-A-blob-3
+ from $new_blob
+ data <<EOF
+ Tag new_blob.
+ EOF
+ INPUT_END
+
+ cat >expect <<-EOF &&
+ object $(git rev-parse refs/heads/master:file3)
+ type blob
+ tag series-A-blob-2
+
+ Tag blob by sha1.
+ object $new_blob
+ type blob
+ tag series-A-blob-3
+
+ Tag new_blob.
+ EOF
+
+ git fast-import <input &&
git cat-file tag tags/series-A-blob-2 >actual &&
git cat-file tag tags/series-A-blob-3 >>actual &&
- test_cmp expect actual'
+ test_cmp expect actual
+'
+
+test_expect_success 'A: verify marks import does not crash' '
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/verify--import-marks
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ recreate from :5
+ COMMIT
-test_tick
-cat >input <<INPUT_END
-commit refs/heads/verify--import-marks
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-recreate from :5
-COMMIT
+ from :5
+ M 755 :2 copy-of-file2
-from :5
-M 755 :2 copy-of-file2
+ INPUT_END
-INPUT_END
-test_expect_success \
- 'A: verify marks import does not crash' \
- 'git fast-import --import-marks=marks.out <input &&
- git whatchanged verify--import-marks'
+ git fast-import --import-marks=marks.out <input &&
+ git whatchanged verify--import-marks
+'
test_expect_success 'A: verify pack' '
verify_packs
'
-cat >expect <<EOF
-:000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
-EOF
-git diff-tree -M -r master verify--import-marks >actual
-test_expect_success \
- 'A: verify diff' \
- 'compare_diff_raw expect actual &&
- test `git rev-parse --verify master:file2` \
- = `git rev-parse --verify verify--import-marks:copy-of-file2`'
-
-test_tick
-mt=$(git hash-object --stdin < /dev/null)
-: >input.blob
-: >marks.exp
-: >tree.exp
-
-cat >input.commit <<EOF
-commit refs/heads/verify--dump-marks
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-test the sparse array dumping routines with exponentially growing marks
-COMMIT
-EOF
-
-i=0
-l=4
-m=6
-n=7
-while test "$i" -lt 27; do
- cat >>input.blob <<EOF
-blob
-mark :$l
-data 0
-blob
-mark :$m
-data 0
-blob
-mark :$n
-data 0
-EOF
- echo "M 100644 :$l l$i" >>input.commit
- echo "M 100644 :$m m$i" >>input.commit
- echo "M 100644 :$n n$i" >>input.commit
-
- echo ":$l $mt" >>marks.exp
- echo ":$m $mt" >>marks.exp
- echo ":$n $mt" >>marks.exp
-
- printf "100644 blob $mt\tl$i\n" >>tree.exp
- printf "100644 blob $mt\tm$i\n" >>tree.exp
- printf "100644 blob $mt\tn$i\n" >>tree.exp
-
- l=$(($l + $l))
- m=$(($m + $m))
- n=$(($l + $n))
-
- i=$((1 + $i))
-done
-
-sort tree.exp > tree.exp_s
+test_expect_success 'A: verify diff' '
+ cat >expect <<-EOF &&
+ :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
+ EOF
+ git diff-tree -M -r master verify--import-marks >actual &&
+ compare_diff_raw expect actual &&
+ test `git rev-parse --verify master:file2` \
+ = `git rev-parse --verify verify--import-marks:copy-of-file2`
+'
test_expect_success 'A: export marks with large values' '
+ test_tick &&
+ mt=$(git hash-object --stdin < /dev/null) &&
+ >input.blob &&
+ >marks.exp &&
+ >tree.exp &&
+
+ cat >input.commit <<-EOF &&
+ commit refs/heads/verify--dump-marks
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ test the sparse array dumping routines with exponentially growing marks
+ COMMIT
+ EOF
+
+ i=0 l=4 m=6 n=7 &&
+ while test "$i" -lt 27
+ do
+ cat >>input.blob <<-EOF &&
+ blob
+ mark :$l
+ data 0
+ blob
+ mark :$m
+ data 0
+ blob
+ mark :$n
+ data 0
+ EOF
+ echo "M 100644 :$l l$i" >>input.commit &&
+ echo "M 100644 :$m m$i" >>input.commit &&
+ echo "M 100644 :$n n$i" >>input.commit &&
+
+ echo ":$l $mt" >>marks.exp &&
+ echo ":$m $mt" >>marks.exp &&
+ echo ":$n $mt" >>marks.exp &&
+
+ printf "100644 blob $mt\tl$i\n" >>tree.exp &&
+ printf "100644 blob $mt\tm$i\n" >>tree.exp &&
+ printf "100644 blob $mt\tn$i\n" >>tree.exp &&
+
+ l=$(($l + $l)) &&
+ m=$(($m + $m)) &&
+ n=$(($l + $n)) &&
+
+ i=$((1 + $i)) || return 1
+ done &&
+
+ sort tree.exp > tree.exp_s &&
+
cat input.blob input.commit | git fast-import --export-marks=marks.large &&
git ls-tree refs/heads/verify--dump-marks >tree.out &&
test_cmp tree.exp_s tree.out &&
- test_cmp marks.exp marks.large'
+ test_cmp marks.exp marks.large
+'
###
### series B
###
-test_tick
-cat >input <<INPUT_END
-commit refs/heads/branch
-mark :1
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-corrupt
-COMMIT
+test_expect_success 'B: fail on invalid blob sha1' '
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/branch
+ mark :1
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ corrupt
+ COMMIT
+
+ from refs/heads/master
+ M 755 0000000000000000000000000000000000000001 zero1
-from refs/heads/master
-M 755 0000000000000000000000000000000000000001 zero1
+ INPUT_END
+
+ test_when_finished "rm -f .git/objects/pack_* .git/objects/index_*" &&
+ test_must_fail git fast-import <input
+'
+
+test_expect_success 'B: accept branch name "TEMP_TAG"' '
+ cat >input <<-INPUT_END &&
+ commit TEMP_TAG
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ tag base
+ COMMIT
+
+ from refs/heads/master
+
+ INPUT_END
+
+ test_when_finished "rm -f .git/TEMP_TAG
+ git gc
+ git prune" &&
+ git fast-import <input &&
+ test -f .git/TEMP_TAG &&
+ test `git rev-parse master` = `git rev-parse TEMP_TAG^`
+'
-INPUT_END
-test_expect_success 'B: fail on invalid blob sha1' '
- test_must_fail git fast-import <input
-'
-rm -f .git/objects/pack_* .git/objects/index_*
-
-cat >input <<INPUT_END
-commit TEMP_TAG
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-tag base
-COMMIT
-
-from refs/heads/master
-
-INPUT_END
-test_expect_success \
- 'B: accept branch name "TEMP_TAG"' \
- 'git fast-import <input &&
- test -f .git/TEMP_TAG &&
- test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
-rm -f .git/TEMP_TAG
-
-git gc 2>/dev/null >/dev/null
-git prune 2>/dev/null >/dev/null
-
-cat >input <<INPUT_END
-commit refs/heads/empty-committer-1
-committer <> $GIT_COMMITTER_DATE
-data <<COMMIT
-empty commit
-COMMIT
-INPUT_END
test_expect_success 'B: accept empty committer' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/empty-committer-1
+ committer <> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ empty commit
+ COMMIT
+ INPUT_END
+
+ test_when_finished "git update-ref -d refs/heads/empty-committer-1
+ git gc
+ git prune" &&
git fast-import <input &&
out=$(git fsck) &&
echo "$out" &&
test -z "$out"
'
-git update-ref -d refs/heads/empty-committer-1 || true
-
-git gc 2>/dev/null >/dev/null
-git prune 2>/dev/null >/dev/null
-cat >input <<INPUT_END
-commit refs/heads/empty-committer-2
-committer <a@b.com> $GIT_COMMITTER_DATE
-data <<COMMIT
-empty commit
-COMMIT
-INPUT_END
test_expect_success 'B: accept and fixup committer with no name' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/empty-committer-2
+ committer <a@b.com> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ empty commit
+ COMMIT
+ INPUT_END
+
+ test_when_finished "git update-ref -d refs/heads/empty-committer-2
+ git gc
+ git prune" &&
git fast-import <input &&
out=$(git fsck) &&
echo "$out" &&
test -z "$out"
'
-git update-ref -d refs/heads/empty-committer-2 || true
-git gc 2>/dev/null >/dev/null
-git prune 2>/dev/null >/dev/null
-
-cat >input <<INPUT_END
-commit refs/heads/invalid-committer
-committer Name email> $GIT_COMMITTER_DATE
-data <<COMMIT
-empty commit
-COMMIT
-INPUT_END
test_expect_success 'B: fail on invalid committer (1)' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/invalid-committer
+ committer Name email> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ empty commit
+ COMMIT
+ INPUT_END
+
+ test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
test_must_fail git fast-import <input
'
-git update-ref -d refs/heads/invalid-committer || true
-cat >input <<INPUT_END
-commit refs/heads/invalid-committer
-committer Name <e<mail> $GIT_COMMITTER_DATE
-data <<COMMIT
-empty commit
-COMMIT
-INPUT_END
test_expect_success 'B: fail on invalid committer (2)' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/invalid-committer
+ committer Name <e<mail> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ empty commit
+ COMMIT
+ INPUT_END
+
+ test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
test_must_fail git fast-import <input
'
-git update-ref -d refs/heads/invalid-committer || true
-cat >input <<INPUT_END
-commit refs/heads/invalid-committer
-committer Name <email>> $GIT_COMMITTER_DATE
-data <<COMMIT
-empty commit
-COMMIT
-INPUT_END
test_expect_success 'B: fail on invalid committer (3)' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/invalid-committer
+ committer Name <email>> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ empty commit
+ COMMIT
+ INPUT_END
+
+ test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
test_must_fail git fast-import <input
'
-git update-ref -d refs/heads/invalid-committer || true
-cat >input <<INPUT_END
-commit refs/heads/invalid-committer
-committer Name <email $GIT_COMMITTER_DATE
-data <<COMMIT
-empty commit
-COMMIT
-INPUT_END
test_expect_success 'B: fail on invalid committer (4)' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/invalid-committer
+ committer Name <email $GIT_COMMITTER_DATE
+ data <<COMMIT
+ empty commit
+ COMMIT
+ INPUT_END
+
+ test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
test_must_fail git fast-import <input
'
-git update-ref -d refs/heads/invalid-committer || true
-cat >input <<INPUT_END
-commit refs/heads/invalid-committer
-committer Name<email> $GIT_COMMITTER_DATE
-data <<COMMIT
-empty commit
-COMMIT
-INPUT_END
test_expect_success 'B: fail on invalid committer (5)' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/invalid-committer
+ committer Name<email> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ empty commit
+ COMMIT
+ INPUT_END
+
+ test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
test_must_fail git fast-import <input
'
-git update-ref -d refs/heads/invalid-committer || true
###
### series C
###
-newf=`echo hi newf | git hash-object -w --stdin`
-oldf=`git rev-parse --verify master:file2`
-test_tick
-cat >input <<INPUT_END
-commit refs/heads/branch
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-second
-COMMIT
-
-from refs/heads/master
-M 644 $oldf file2/oldf
-M 755 $newf file2/newf
-D file3
-
-INPUT_END
-test_expect_success \
- 'C: incremental import create pack from stdin' \
- 'git fast-import <input &&
- git whatchanged branch'
+test_expect_success 'C: incremental import create pack from stdin' '
+ newf=`echo hi newf | git hash-object -w --stdin` &&
+ oldf=`git rev-parse --verify master:file2` &&
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/branch
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ second
+ COMMIT
+
+ from refs/heads/master
+ M 644 $oldf file2/oldf
+ M 755 $newf file2/newf
+ D file3
+
+ INPUT_END
+
+ git fast-import <input &&
+ git whatchanged branch
+'
test_expect_success 'C: verify pack' '
verify_packs
'
-test_expect_success \
- 'C: validate reuse existing blob' \
- 'test $newf = `git rev-parse --verify branch:file2/newf` &&
- test $oldf = `git rev-parse --verify branch:file2/oldf`'
-
-cat >expect <<EOF
-parent `git rev-parse --verify master^0`
-author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-
-second
-EOF
-test_expect_success \
- 'C: verify commit' \
- 'git cat-file commit branch | sed 1d >actual &&
- test_cmp expect actual'
-
-cat >expect <<EOF
-:000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
-:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
-:100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
-EOF
-git diff-tree -M -r master branch >actual
-test_expect_success \
- 'C: validate rename result' \
- 'compare_diff_raw expect actual'
+test_expect_success 'C: validate reuse existing blob' '
+ test $newf = `git rev-parse --verify branch:file2/newf` &&
+ test $oldf = `git rev-parse --verify branch:file2/oldf`
+'
+
+test_expect_success 'C: verify commit' '
+ cat >expect <<-EOF &&
+ parent `git rev-parse --verify master^0`
+ author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+ second
+ EOF
+
+ git cat-file commit branch | sed 1d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'C: validate rename result' '
+ cat >expect <<-EOF &&
+ :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
+ :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
+ :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
+ EOF
+ git diff-tree -M -r master branch >actual &&
+ compare_diff_raw expect actual
+'
###
### series D
###
-test_tick
-cat >input <<INPUT_END
-commit refs/heads/branch
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-third
-COMMIT
-
-from refs/heads/branch^0
-M 644 inline newdir/interesting
-data <<EOF
-$file5_data
-EOF
-
-M 755 inline newdir/exec.sh
-data <<EOF
-$file6_data
-EOF
-
-INPUT_END
-test_expect_success \
- 'D: inline data in commit' \
- 'git fast-import <input &&
- git whatchanged branch'
+test_expect_success 'D: inline data in commit' '
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/branch
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ third
+ COMMIT
+
+ from refs/heads/branch^0
+ M 644 inline newdir/interesting
+ data <<EOF
+ $file5_data
+ EOF
+
+ M 755 inline newdir/exec.sh
+ data <<EOF
+ $file6_data
+ EOF
+
+ INPUT_END
+
+ git fast-import <input &&
+ git whatchanged branch
+'
test_expect_success 'D: verify pack' '
verify_packs
'
-cat >expect <<EOF
-:000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
-:000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
-EOF
-git diff-tree -M -r branch^ branch >actual
-test_expect_success \
- 'D: validate new files added' \
- 'compare_diff_raw expect actual'
+test_expect_success 'D: validate new files added' '
+ cat >expect <<-EOF &&
+ :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
+ :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
+ EOF
+ git diff-tree -M -r branch^ branch >actual &&
+ compare_diff_raw expect actual
+'
-echo "$file5_data" >expect
-test_expect_success \
- 'D: verify file5' \
- 'git cat-file blob branch:newdir/interesting >actual &&
- test_cmp expect actual'
+test_expect_success 'D: verify file5' '
+ echo "$file5_data" >expect &&
+ git cat-file blob branch:newdir/interesting >actual &&
+ test_cmp expect actual
+'
-echo "$file6_data" >expect
-test_expect_success \
- 'D: verify file6' \
- 'git cat-file blob branch:newdir/exec.sh >actual &&
- test_cmp expect actual'
+test_expect_success 'D: verify file6' '
+ echo "$file6_data" >expect &&
+ git cat-file blob branch:newdir/exec.sh >actual &&
+ test_cmp expect actual
+'
###
### series E
###
-cat >input <<INPUT_END
-commit refs/heads/branch
-author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
-data <<COMMIT
-RFC 2822 type date
-COMMIT
+test_expect_success 'E: rfc2822 date, --date-format=raw' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/branch
+ author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
+ data <<COMMIT
+ RFC 2822 type date
+ COMMIT
-from refs/heads/branch^0
+ from refs/heads/branch^0
-INPUT_END
-test_expect_success 'E: rfc2822 date, --date-format=raw' '
- test_must_fail git fast-import --date-format=raw <input
+ INPUT_END
+
+ test_must_fail git fast-import --date-format=raw <input
+'
+test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
+ git fast-import --date-format=rfc2822 <input
'
-test_expect_success \
- 'E: rfc2822 date, --date-format=rfc2822' \
- 'git fast-import --date-format=rfc2822 <input'
test_expect_success 'E: verify pack' '
verify_packs
'
-cat >expect <<EOF
-author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
+test_expect_success 'E: verify commit' '
+ cat >expect <<-EOF &&
+ author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
-RFC 2822 type date
-EOF
-test_expect_success \
- 'E: verify commit' \
- 'git cat-file commit branch | sed 1,2d >actual &&
- test_cmp expect actual'
+ RFC 2822 type date
+ EOF
+ git cat-file commit branch | sed 1,2d >actual &&
+ test_cmp expect actual
+'
###
### series F
###
-old_branch=`git rev-parse --verify branch^0`
-test_tick
-cat >input <<INPUT_END
-commit refs/heads/branch
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-losing things already?
-COMMIT
-
-from refs/heads/branch~1
-
-reset refs/heads/other
-from refs/heads/branch
-
-INPUT_END
-test_expect_success \
- 'F: non-fast-forward update skips' \
- 'if git fast-import <input
- then
- echo BAD gfi did not fail
- return 1
- else
- if test $old_branch = `git rev-parse --verify branch^0`
- then
- : branch unaffected and failure returned
- return 0
- else
- echo BAD gfi changed branch $old_branch
- return 1
- fi
- fi
- '
+test_expect_success 'F: non-fast-forward update skips' '
+ old_branch=`git rev-parse --verify branch^0` &&
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/branch
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ losing things already?
+ COMMIT
+
+ from refs/heads/branch~1
+
+ reset refs/heads/other
+ from refs/heads/branch
+
+ INPUT_END
+
+ test_must_fail git fast-import <input &&
+ # branch must remain unaffected
+ test $old_branch = `git rev-parse --verify branch^0`
+'
test_expect_success 'F: verify pack' '
verify_packs
'
-cat >expect <<EOF
-tree `git rev-parse branch~1^{tree}`
-parent `git rev-parse branch~1`
-author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+test_expect_success 'F: verify other commit' '
+ cat >expect <<-EOF &&
+ tree `git rev-parse branch~1^{tree}`
+ parent `git rev-parse branch~1`
+ author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-losing things already?
-EOF
-test_expect_success \
- 'F: verify other commit' \
- 'git cat-file commit other >actual &&
- test_cmp expect actual'
+ losing things already?
+ EOF
+ git cat-file commit other >actual &&
+ test_cmp expect actual
+'
###
### series G
###
-old_branch=`git rev-parse --verify branch^0`
-test_tick
-cat >input <<INPUT_END
-commit refs/heads/branch
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-losing things already?
-COMMIT
+test_expect_success 'G: non-fast-forward update forced' '
+ old_branch=`git rev-parse --verify branch^0` &&
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/branch
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ losing things already?
+ COMMIT
-from refs/heads/branch~1
+ from refs/heads/branch~1
-INPUT_END
-test_expect_success \
- 'G: non-fast-forward update forced' \
- 'git fast-import --force <input'
+ INPUT_END
+ git fast-import --force <input
+'
test_expect_success 'G: verify pack' '
verify_packs
'
-test_expect_success \
- 'G: branch changed, but logged' \
- 'test $old_branch != `git rev-parse --verify branch^0` &&
- test $old_branch = `git rev-parse --verify branch@{1}`'
+test_expect_success 'G: branch changed, but logged' '
+ test $old_branch != `git rev-parse --verify branch^0` &&
+ test $old_branch = `git rev-parse --verify branch@{1}`
+'
###
### series H
###
-test_tick
-cat >input <<INPUT_END
-commit refs/heads/H
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-third
-COMMIT
-
-from refs/heads/branch^0
-M 644 inline i-will-die
-data <<EOF
-this file will never exist.
-EOF
-
-deleteall
-M 644 inline h/e/l/lo
-data <<EOF
-$file5_data
-EOF
-
-INPUT_END
-test_expect_success \
- 'H: deletall, add 1' \
- 'git fast-import <input &&
- git whatchanged H'
+test_expect_success 'H: deletall, add 1' '
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/H
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ third
+ COMMIT
+
+ from refs/heads/branch^0
+ M 644 inline i-will-die
+ data <<EOF
+ this file will never exist.
+ EOF
+
+ deleteall
+ M 644 inline h/e/l/lo
+ data <<EOF
+ $file5_data
+ EOF
+
+ INPUT_END
+ git fast-import <input &&
+ git whatchanged H
+'
test_expect_success 'H: verify pack' '
verify_packs
'
-cat >expect <<EOF
-:100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
-:100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
-:100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
-:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
-:100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
-EOF
-git diff-tree -M -r H^ H >actual
-test_expect_success \
- 'H: validate old files removed, new files added' \
- 'compare_diff_raw expect actual'
-
-echo "$file5_data" >expect
-test_expect_success \
- 'H: verify file' \
- 'git cat-file blob H:h/e/l/lo >actual &&
- test_cmp expect actual'
+test_expect_success 'H: validate old files removed, new files added' '
+ cat >expect <<-EOF &&
+ :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
+ :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
+ :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
+ :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
+ :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
+ EOF
+ git diff-tree -M -r H^ H >actual &&
+ compare_diff_raw expect actual
+'
+
+test_expect_success 'H: verify file' '
+ echo "$file5_data" >expect &&
+ git cat-file blob H:h/e/l/lo >actual &&
+ test_cmp expect actual
+'
###
### series I
###
-cat >input <<INPUT_END
-commit refs/heads/export-boundary
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-we have a border. its only 40 characters wide.
-COMMIT
+test_expect_success 'I: export-pack-edges' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/export-boundary
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ we have a border. its only 40 characters wide.
+ COMMIT
-from refs/heads/branch
+ from refs/heads/branch
-INPUT_END
-test_expect_success \
- 'I: export-pack-edges' \
- 'git fast-import --export-pack-edges=edges.list <input'
+ INPUT_END
+ git fast-import --export-pack-edges=edges.list <input
+'
-cat >expect <<EOF
-.git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
-EOF
-test_expect_success \
- 'I: verify edge list' \
- 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
- test_cmp expect actual'
+test_expect_success 'I: verify edge list' '
+ cat >expect <<-EOF &&
+ .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
+ EOF
+ sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
+ test_cmp expect actual
+'
###
### series J
###
-cat >input <<INPUT_END
-commit refs/heads/J
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-create J
-COMMIT
-
-from refs/heads/branch
-
-reset refs/heads/J
-
-commit refs/heads/J
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-initialize J
-COMMIT
-
-INPUT_END
-test_expect_success \
- 'J: reset existing branch creates empty commit' \
- 'git fast-import <input'
-test_expect_success \
- 'J: branch has 1 commit, empty tree' \
- 'test 1 = `git rev-list J | wc -l` &&
- test 0 = `git ls-tree J | wc -l`'
-
-cat >input <<INPUT_END
-reset refs/heads/J2
-
-tag wrong_tag
-from refs/heads/J2
-data <<EOF
-Tag branch that was reset.
-EOF
-INPUT_END
-test_expect_success \
- 'J: tag must fail on empty branch' \
- 'test_must_fail git fast-import <input'
+test_expect_success 'J: reset existing branch creates empty commit' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/J
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ create J
+ COMMIT
+
+ from refs/heads/branch
+
+ reset refs/heads/J
+
+ commit refs/heads/J
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ initialize J
+ COMMIT
+
+ INPUT_END
+ git fast-import <input
+'
+test_expect_success 'J: branch has 1 commit, empty tree' '
+ test 1 = `git rev-list J | wc -l` &&
+ test 0 = `git ls-tree J | wc -l`
+'
+
+test_expect_success 'J: tag must fail on empty branch' '
+ cat >input <<-INPUT_END &&
+ reset refs/heads/J2
+
+ tag wrong_tag
+ from refs/heads/J2
+ data <<EOF
+ Tag branch that was reset.
+ EOF
+ INPUT_END
+ test_must_fail git fast-import <input
+'
+
###
### series K
###
-cat >input <<INPUT_END
-commit refs/heads/K
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-create K
-COMMIT
+test_expect_success 'K: reinit branch with from' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/K
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ create K
+ COMMIT
-from refs/heads/branch
+ from refs/heads/branch
-commit refs/heads/K
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-redo K
-COMMIT
+ commit refs/heads/K
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ redo K
+ COMMIT
-from refs/heads/branch^1
+ from refs/heads/branch^1
-INPUT_END
-test_expect_success \
- 'K: reinit branch with from' \
- 'git fast-import <input'
-test_expect_success \
- 'K: verify K^1 = branch^1' \
- 'test `git rev-parse --verify branch^1` \
- = `git rev-parse --verify K^1`'
+ INPUT_END
+ git fast-import <input
+'
+test_expect_success 'K: verify K^1 = branch^1' '
+ test `git rev-parse --verify branch^1` \
+ = `git rev-parse --verify K^1`
+'
###
### series L
###
-cat >input <<INPUT_END
-blob
-mark :1
-data <<EOF
-some data
-EOF
-
-blob
-mark :2
-data <<EOF
-other data
-EOF
-
-commit refs/heads/L
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-create L
-COMMIT
-
-M 644 :1 b.
-M 644 :1 b/other
-M 644 :1 ba
-
-commit refs/heads/L
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-update L
-COMMIT
-
-M 644 :2 b.
-M 644 :2 b/other
-M 644 :2 ba
-INPUT_END
-
-cat >expect <<EXPECT_END
-:100644 100644 4268632... 55d3a52... M b.
-:040000 040000 0ae5cac... 443c768... M b
-:100644 100644 4268632... 55d3a52... M ba
-EXPECT_END
-
-test_expect_success \
- 'L: verify internal tree sorting' \
- 'git fast-import <input &&
- git diff-tree --abbrev --raw L^ L >output &&
- test_cmp expect output'
-
-cat >input <<INPUT_END
-blob
-mark :1
-data <<EOF
-the data
-EOF
-
-commit refs/heads/L2
-committer C O Mitter <committer@example.com> 1112912473 -0700
-data <<COMMIT
-init L2
-COMMIT
-M 644 :1 a/b/c
-M 644 :1 a/b/d
-M 644 :1 a/e/f
-
-commit refs/heads/L2
-committer C O Mitter <committer@example.com> 1112912473 -0700
-data <<COMMIT
-update L2
-COMMIT
-C a g
-C a/e g/b
-M 644 :1 g/b/h
-INPUT_END
-
-cat <<EOF >expect
-g/b/f
-g/b/h
-EOF
-
-test_expect_success \
- 'L: nested tree copy does not corrupt deltas' \
- 'git fast-import <input &&
+test_expect_success 'L: verify internal tree sorting' '
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ some data
+ EOF
+
+ blob
+ mark :2
+ data <<EOF
+ other data
+ EOF
+
+ commit refs/heads/L
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ create L
+ COMMIT
+
+ M 644 :1 b.
+ M 644 :1 b/other
+ M 644 :1 ba
+
+ commit refs/heads/L
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ update L
+ COMMIT
+
+ M 644 :2 b.
+ M 644 :2 b/other
+ M 644 :2 ba
+ INPUT_END
+
+ cat >expect <<-EXPECT_END &&
+ :100644 100644 4268632... 55d3a52... M b.
+ :040000 040000 0ae5cac... 443c768... M b
+ :100644 100644 4268632... 55d3a52... M ba
+ EXPECT_END
+
+ git fast-import <input &&
+ git diff-tree --abbrev --raw L^ L >output &&
+ test_cmp expect output
+'
+
+test_expect_success 'L: nested tree copy does not corrupt deltas' '
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<EOF
+ the data
+ EOF
+
+ commit refs/heads/L2
+ committer C O Mitter <committer@example.com> 1112912473 -0700
+ data <<COMMIT
+ init L2
+ COMMIT
+ M 644 :1 a/b/c
+ M 644 :1 a/b/d
+ M 644 :1 a/e/f
+
+ commit refs/heads/L2
+ committer C O Mitter <committer@example.com> 1112912473 -0700
+ data <<COMMIT
+ update L2
+ COMMIT
+ C a g
+ C a/e g/b
+ M 644 :1 g/b/h
+ INPUT_END
+
+ cat >expect <<-\EOF &&
+ g/b/f
+ g/b/h
+ EOF
+
+ test_when_finished "git update-ref -d refs/heads/L2" &&
+ git fast-import <input &&
git ls-tree L2 g/b/ >tmp &&
cat tmp | cut -f 2 >actual &&
test_cmp expect actual &&
- git fsck `git rev-parse L2`'
-
-git update-ref -d refs/heads/L2
+ git fsck `git rev-parse L2`
+'
###
### series M
###
-test_tick
-cat >input <<INPUT_END
-commit refs/heads/M1
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-file rename
-COMMIT
-
-from refs/heads/branch^0
-R file2/newf file2/n.e.w.f
-
-INPUT_END
-
-cat >expect <<EOF
-:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
-EOF
-test_expect_success \
- 'M: rename file in same subdirectory' \
- 'git fast-import <input &&
- git diff-tree -M -r M1^ M1 >actual &&
- compare_diff_raw expect actual'
-
-cat >input <<INPUT_END
-commit refs/heads/M2
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-file rename
-COMMIT
-
-from refs/heads/branch^0
-R file2/newf i/am/new/to/you
-
-INPUT_END
-
-cat >expect <<EOF
-:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
-EOF
-test_expect_success \
- 'M: rename file to new subdirectory' \
- 'git fast-import <input &&
- git diff-tree -M -r M2^ M2 >actual &&
- compare_diff_raw expect actual'
-
-cat >input <<INPUT_END
-commit refs/heads/M3
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-file rename
-COMMIT
-
-from refs/heads/M2^0
-R i other/sub
-
-INPUT_END
-
-cat >expect <<EOF
-:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
-EOF
-test_expect_success \
- 'M: rename subdirectory to new subdirectory' \
- 'git fast-import <input &&
- git diff-tree -M -r M3^ M3 >actual &&
- compare_diff_raw expect actual'
-
-cat >input <<INPUT_END
-commit refs/heads/M4
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-rename root
-COMMIT
-
-from refs/heads/M2^0
-R "" sub
-
-INPUT_END
-
-cat >expect <<EOF
-:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
-:100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
-:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
-:100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
-:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
-EOF
-test_expect_success \
- 'M: rename root to subdirectory' \
- 'git fast-import <input &&
- git diff-tree -M -r M4^ M4 >actual &&
- cat actual &&
- compare_diff_raw expect actual'
+test_expect_success 'M: rename file in same subdirectory' '
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/M1
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ file rename
+ COMMIT
+
+ from refs/heads/branch^0
+ R file2/newf file2/n.e.w.f
+
+ INPUT_END
+
+ cat >expect <<-EOF &&
+ :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
+ EOF
+ git fast-import <input &&
+ git diff-tree -M -r M1^ M1 >actual &&
+ compare_diff_raw expect actual
+'
+
+test_expect_success 'M: rename file to new subdirectory' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/M2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ file rename
+ COMMIT
+
+ from refs/heads/branch^0
+ R file2/newf i/am/new/to/you
+
+ INPUT_END
+
+ cat >expect <<-EOF &&
+ :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
+ EOF
+ git fast-import <input &&
+ git diff-tree -M -r M2^ M2 >actual &&
+ compare_diff_raw expect actual
+'
+
+test_expect_success 'M: rename subdirectory to new subdirectory' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/M3
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ file rename
+ COMMIT
+
+ from refs/heads/M2^0
+ R i other/sub
+
+ INPUT_END
+
+ cat >expect <<-EOF &&
+ :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
+ EOF
+ git fast-import <input &&
+ git diff-tree -M -r M3^ M3 >actual &&
+ compare_diff_raw expect actual
+'
+
+test_expect_success 'M: rename root to subdirectory' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/M4
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ rename root
+ COMMIT
+
+ from refs/heads/M2^0
+ R "" sub
+
+ INPUT_END
+
+ cat >expect <<-EOF &&
+ :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
+ :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
+ :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
+ :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
+ :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
+ EOF
+ git fast-import <input &&
+ git diff-tree -M -r M4^ M4 >actual &&
+ cat actual &&
+ compare_diff_raw expect actual
+'
###
### series N
###
-test_tick
-cat >input <<INPUT_END
-commit refs/heads/N1
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-file copy
-COMMIT
-
-from refs/heads/branch^0
-C file2/newf file2/n.e.w.f
-
-INPUT_END
-
-cat >expect <<EOF
-:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
-EOF
-test_expect_success \
- 'N: copy file in same subdirectory' \
- 'git fast-import <input &&
- git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
- compare_diff_raw expect actual'
-
-cat >input <<INPUT_END
-commit refs/heads/N2
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-clean directory copy
-COMMIT
-
-from refs/heads/branch^0
-C file2 file3
-
-commit refs/heads/N2
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-modify directory copy
-COMMIT
-
-M 644 inline file3/file5
-data <<EOF
-$file5_data
-EOF
-
-INPUT_END
-
-cat >expect <<EOF
-:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
-:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
-:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
-EOF
-test_expect_success \
- 'N: copy then modify subdirectory' \
- 'git fast-import <input &&
- git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
- compare_diff_raw expect actual'
-
-cat >input <<INPUT_END
-commit refs/heads/N3
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-dirty directory copy
-COMMIT
-
-from refs/heads/branch^0
-M 644 inline file2/file5
-data <<EOF
-$file5_data
-EOF
-
-C file2 file3
-D file2/file5
-
-INPUT_END
-
-test_expect_success \
- 'N: copy dirty subdirectory' \
- 'git fast-import <input &&
- test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
-
-test_expect_success \
- 'N: copy directory by id' \
- 'cat >expect <<-\EOF &&
+test_expect_success 'N: copy file in same subdirectory' '
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/N1
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ file copy
+ COMMIT
+
+ from refs/heads/branch^0
+ C file2/newf file2/n.e.w.f
+
+ INPUT_END
+
+ cat >expect <<-EOF &&
+ :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
+ EOF
+ git fast-import <input &&
+ git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
+ compare_diff_raw expect actual
+'
+
+test_expect_success 'N: copy then modify subdirectory' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/N2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ clean directory copy
+ COMMIT
+
+ from refs/heads/branch^0
+ C file2 file3
+
+ commit refs/heads/N2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ modify directory copy
+ COMMIT
+
+ M 644 inline file3/file5
+ data <<EOF
+ $file5_data
+ EOF
+
+ INPUT_END
+
+ cat >expect <<-EOF &&
+ :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
EOF
- subdir=$(git rev-parse refs/heads/branch^0:file2) &&
- cat >input <<-INPUT_END &&
+ git fast-import <input &&
+ git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
+ compare_diff_raw expect actual
+'
+
+test_expect_success 'N: copy dirty subdirectory' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/N3
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ dirty directory copy
+ COMMIT
+
+ from refs/heads/branch^0
+ M 644 inline file2/file5
+ data <<EOF
+ $file5_data
+ EOF
+
+ C file2 file3
+ D file2/file5
+
+ INPUT_END
+
+ git fast-import <input &&
+ test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`
+'
+
+test_expect_success 'N: copy directory by id' '
+ cat >expect <<-\EOF &&
+ :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
+ :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
+ EOF
+ subdir=$(git rev-parse refs/heads/branch^0:file2) &&
+ cat >input <<-INPUT_END &&
commit refs/heads/N4
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1127,9 +1125,10 @@ test_expect_success \
from refs/heads/branch^0
M 040000 $subdir file3
INPUT_END
- git fast-import <input &&
- git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
- compare_diff_raw expect actual'
+ git fast-import <input &&
+ git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
+ compare_diff_raw expect actual
+'
test_expect_success PIPE 'N: read and copy directory' '
cat >expect <<-\EOF &&
@@ -1202,14 +1201,13 @@ test_expect_success PIPE 'N: empty directory reads as missing' '
test_cmp expect actual
'
-test_expect_success \
- 'N: copy root directory by tree hash' \
- 'cat >expect <<-\EOF &&
+test_expect_success 'N: copy root directory by tree hash' '
+ cat >expect <<-\EOF &&
:100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
:100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
EOF
- root=$(git rev-parse refs/heads/branch^0^{tree}) &&
- cat >input <<-INPUT_END &&
+ root=$(git rev-parse refs/heads/branch^0^{tree}) &&
+ cat >input <<-INPUT_END &&
commit refs/heads/N6
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1219,20 +1217,20 @@ test_expect_success \
from refs/heads/branch^0
M 040000 $root ""
INPUT_END
- git fast-import <input &&
- git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
- compare_diff_raw expect actual'
+ git fast-import <input &&
+ git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
+ compare_diff_raw expect actual
+'
-test_expect_success \
- 'N: copy root by path' \
- 'cat >expect <<-\EOF &&
+test_expect_success 'N: copy root by path' '
+ cat >expect <<-\EOF &&
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
:100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
:100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
EOF
- cat >input <<-INPUT_END &&
+ cat >input <<-INPUT_END &&
commit refs/heads/N-copy-root-path
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1242,21 +1240,21 @@ test_expect_success \
from refs/heads/branch^0
C "" oldroot
INPUT_END
- git fast-import <input &&
- git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
- compare_diff_raw expect actual'
+ git fast-import <input &&
+ git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
+ compare_diff_raw expect actual
+'
-test_expect_success \
- 'N: delete directory by copying' \
- 'cat >expect <<-\EOF &&
+test_expect_success 'N: delete directory by copying' '
+ cat >expect <<-\EOF &&
OBJID
:100644 000000 OBJID OBJID D foo/bar/qux
OBJID
:000000 100644 OBJID OBJID A foo/bar/baz
:000000 100644 OBJID OBJID A foo/bar/qux
EOF
- empty_tree=$(git mktree </dev/null) &&
- cat >input <<-INPUT_END &&
+ empty_tree=$(git mktree </dev/null) &&
+ cat >input <<-INPUT_END &&
commit refs/heads/N-delete
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1282,21 +1280,21 @@ test_expect_success \
M 040000 $empty_tree foo/bar/qux
INPUT_END
- git fast-import <input &&
- git rev-list N-delete |
+ git fast-import <input &&
+ git rev-list N-delete |
git diff-tree -r --stdin --root --always |
sed -e "s/$_x40/OBJID/g" >actual &&
- test_cmp expect actual'
+ test_cmp expect actual
+'
-test_expect_success \
- 'N: modify copied tree' \
- 'cat >expect <<-\EOF &&
+test_expect_success 'N: modify copied tree' '
+ cat >expect <<-\EOF &&
:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
EOF
- subdir=$(git rev-parse refs/heads/branch^0:file2) &&
- cat >input <<-INPUT_END &&
+ subdir=$(git rev-parse refs/heads/branch^0:file2) &&
+ cat >input <<-INPUT_END &&
commit refs/heads/N5
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1317,14 +1315,14 @@ test_expect_success \
$file5_data
EOF
INPUT_END
- git fast-import <input &&
- git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
- compare_diff_raw expect actual'
-
-test_expect_success \
- 'N: reject foo/ syntax' \
- 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
- test_must_fail git fast-import <<-INPUT_END
+ git fast-import <input &&
+ git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
+ compare_diff_raw expect actual
+'
+
+test_expect_success 'N: reject foo/ syntax' '
+ subdir=$(git rev-parse refs/heads/branch^0:file2) &&
+ test_must_fail git fast-import <<-INPUT_END
commit refs/heads/N5B
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1333,11 +1331,11 @@ test_expect_success \
from refs/heads/branch^0
M 040000 $subdir file3/
- INPUT_END'
+ INPUT_END
+'
-test_expect_success \
- 'N: reject foo/ syntax in copy source' \
- 'test_must_fail git fast-import <<-INPUT_END
+test_expect_success 'N: reject foo/ syntax in copy source' '
+ test_must_fail git fast-import <<-INPUT_END
commit refs/heads/N5C
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1346,11 +1344,11 @@ test_expect_success \
from refs/heads/branch^0
C file2/ file3
- INPUT_END'
+ INPUT_END
+'
-test_expect_success \
- 'N: reject foo/ syntax in rename source' \
- 'test_must_fail git fast-import <<-INPUT_END
+test_expect_success 'N: reject foo/ syntax in rename source' '
+ test_must_fail git fast-import <<-INPUT_END
commit refs/heads/N5D
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1359,11 +1357,11 @@ test_expect_success \
from refs/heads/branch^0
R file2/ file3
- INPUT_END'
+ INPUT_END
+'
-test_expect_success \
- 'N: reject foo/ syntax in ls argument' \
- 'test_must_fail git fast-import <<-INPUT_END
+test_expect_success 'N: reject foo/ syntax in ls argument' '
+ test_must_fail git fast-import <<-INPUT_END
commit refs/heads/N5E
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1372,13 +1370,13 @@ test_expect_success \
from refs/heads/branch^0
ls "file2/"
- INPUT_END'
+ INPUT_END
+'
-test_expect_success \
- 'N: copy to root by id and modify' \
- 'echo "hello, world" >expect.foo &&
- echo hello >expect.bar &&
- git fast-import <<-SETUP_END &&
+test_expect_success 'N: copy to root by id and modify' '
+ echo "hello, world" >expect.foo &&
+ echo hello >expect.bar &&
+ git fast-import <<-SETUP_END &&
commit refs/heads/N7
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1392,8 +1390,8 @@ test_expect_success \
EOF
SETUP_END
- tree=$(git rev-parse --verify N7:) &&
- git fast-import <<-INPUT_END &&
+ tree=$(git rev-parse --verify N7:) &&
+ git fast-import <<-INPUT_END &&
commit refs/heads/N8
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1406,15 +1404,15 @@ test_expect_success \
hello, world
EOF
INPUT_END
- git show N8:foo/foo >actual.foo &&
- git show N8:foo/bar >actual.bar &&
- test_cmp expect.foo actual.foo &&
- test_cmp expect.bar actual.bar'
-
-test_expect_success \
- 'N: extract subtree' \
- 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
- cat >input <<-INPUT_END &&
+ git show N8:foo/foo >actual.foo &&
+ git show N8:foo/bar >actual.bar &&
+ test_cmp expect.foo actual.foo &&
+ test_cmp expect.bar actual.bar
+'
+
+test_expect_success 'N: extract subtree' '
+ branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
+ cat >input <<-INPUT_END &&
commit refs/heads/N9
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1424,14 +1422,14 @@ test_expect_success \
M 040000 $branch ""
C "newdir" ""
INPUT_END
- git fast-import <input &&
- git diff --exit-code branch:newdir N9'
-
-test_expect_success \
- 'N: modify subtree, extract it, and modify again' \
- 'echo hello >expect.baz &&
- echo hello, world >expect.qux &&
- git fast-import <<-SETUP_END &&
+ git fast-import <input &&
+ git diff --exit-code branch:newdir N9
+'
+
+test_expect_success 'N: modify subtree, extract it, and modify again' '
+ echo hello >expect.baz &&
+ echo hello, world >expect.qux &&
+ git fast-import <<-SETUP_END &&
commit refs/heads/N10
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1445,8 +1443,8 @@ test_expect_success \
EOF
SETUP_END
- tree=$(git rev-parse --verify N10:) &&
- git fast-import <<-INPUT_END &&
+ tree=$(git rev-parse --verify N10:) &&
+ git fast-import <<-INPUT_END &&
commit refs/heads/N11
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
@@ -1461,676 +1459,692 @@ test_expect_success \
R "foo" ""
C "bar/qux" "bar/quux"
INPUT_END
- git show N11:bar/baz >actual.baz &&
- git show N11:bar/qux >actual.qux &&
- git show N11:bar/quux >actual.quux &&
- test_cmp expect.baz actual.baz &&
- test_cmp expect.qux actual.qux &&
- test_cmp expect.qux actual.quux'
+ git show N11:bar/baz >actual.baz &&
+ git show N11:bar/qux >actual.qux &&
+ git show N11:bar/quux >actual.quux &&
+ test_cmp expect.baz actual.baz &&
+ test_cmp expect.qux actual.qux &&
+ test_cmp expect.qux actual.quux'
###
### series O
###
-cat >input <<INPUT_END
-#we will
-commit refs/heads/O1
-# -- ignore all of this text
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-# $GIT_COMMITTER_NAME has inserted here for his benefit.
-data <<COMMIT
-dirty directory copy
-COMMIT
-
-# don't forget the import blank line!
-#
-# yes, we started from our usual base of branch^0.
-# i like branch^0.
-from refs/heads/branch^0
-# and we need to reuse file2/file5 from N3 above.
-M 644 inline file2/file5
-# otherwise the tree will be different
-data <<EOF
-$file5_data
-EOF
-
-# don't forget to copy file2 to file3
-C file2 file3
-#
-# or to delete file5 from file2.
-D file2/file5
-# are we done yet?
-
-INPUT_END
-
-test_expect_success \
- 'O: comments are all skipped' \
- 'git fast-import <input &&
- test `git rev-parse N3` = `git rev-parse O1`'
-
-cat >input <<INPUT_END
-commit refs/heads/O2
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-dirty directory copy
-COMMIT
-from refs/heads/branch^0
-M 644 inline file2/file5
-data <<EOF
-$file5_data
-EOF
-C file2 file3
-D file2/file5
-
-INPUT_END
-
-test_expect_success \
- 'O: blank lines not necessary after data commands' \
- 'git fast-import <input &&
- test `git rev-parse N3` = `git rev-parse O2`'
-
-test_expect_success \
- 'O: repack before next test' \
- 'git repack -a -d'
-
-cat >input <<INPUT_END
-commit refs/heads/O3
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-zstring
-COMMIT
-commit refs/heads/O3
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-zof
-COMMIT
-checkpoint
-commit refs/heads/O3
-mark :5
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-zempty
-COMMIT
-checkpoint
-commit refs/heads/O3
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-zcommits
-COMMIT
-reset refs/tags/O3-2nd
-from :5
-reset refs/tags/O3-3rd
-from :5
-INPUT_END
-
-cat >expect <<INPUT_END
-string
-of
-empty
-commits
-INPUT_END
-test_expect_success \
- 'O: blank lines not necessary after other commands' \
- 'git fast-import <input &&
- test 8 = `find .git/objects/pack -type f | wc -l` &&
- test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
- git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
- test_cmp expect actual'
-
-cat >input <<INPUT_END
-commit refs/heads/O4
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-zstring
-COMMIT
-commit refs/heads/O4
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-zof
-COMMIT
-progress Two commits down, 2 to go!
-commit refs/heads/O4
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-zempty
-COMMIT
-progress Three commits down, 1 to go!
-commit refs/heads/O4
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-zcommits
-COMMIT
-progress I'm done!
-INPUT_END
-test_expect_success \
- 'O: progress outputs as requested by input' \
- 'git fast-import <input >actual &&
- grep "progress " <input >expect &&
- test_cmp expect actual'
+test_expect_success 'O: comments are all skipped' '
+ cat >input <<-INPUT_END &&
+ #we will
+ commit refs/heads/O1
+ # -- ignore all of this text
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ # $GIT_COMMITTER_NAME has inserted here for his benefit.
+ data <<COMMIT
+ dirty directory copy
+ COMMIT
+
+ # do not forget the import blank line!
+ #
+ # yes, we started from our usual base of branch^0.
+ # i like branch^0.
+ from refs/heads/branch^0
+ # and we need to reuse file2/file5 from N3 above.
+ M 644 inline file2/file5
+ # otherwise the tree will be different
+ data <<EOF
+ $file5_data
+ EOF
+
+ # do not forget to copy file2 to file3
+ C file2 file3
+ #
+ # or to delete file5 from file2.
+ D file2/file5
+ # are we done yet?
+
+ INPUT_END
+
+ git fast-import <input &&
+ test `git rev-parse N3` = `git rev-parse O1`
+'
+
+test_expect_success 'O: blank lines not necessary after data commands' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/O2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ dirty directory copy
+ COMMIT
+ from refs/heads/branch^0
+ M 644 inline file2/file5
+ data <<EOF
+ $file5_data
+ EOF
+ C file2 file3
+ D file2/file5
+
+ INPUT_END
+
+ git fast-import <input &&
+ test `git rev-parse N3` = `git rev-parse O2`
+'
+
+test_expect_success 'O: repack before next test' '
+ git repack -a -d
+'
+
+test_expect_success 'O: blank lines not necessary after other commands' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/O3
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ zstring
+ COMMIT
+ commit refs/heads/O3
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ zof
+ COMMIT
+ checkpoint
+ commit refs/heads/O3
+ mark :5
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ zempty
+ COMMIT
+ checkpoint
+ commit refs/heads/O3
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ zcommits
+ COMMIT
+ reset refs/tags/O3-2nd
+ from :5
+ reset refs/tags/O3-3rd
+ from :5
+ INPUT_END
+
+ cat >expect <<-INPUT_END &&
+ string
+ of
+ empty
+ commits
+ INPUT_END
+
+ git fast-import <input &&
+ test 8 = `find .git/objects/pack -type f | wc -l` &&
+ test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
+ git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'O: progress outputs as requested by input' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/O4
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ zstring
+ COMMIT
+ commit refs/heads/O4
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ zof
+ COMMIT
+ progress Two commits down, 2 to go!
+ commit refs/heads/O4
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ zempty
+ COMMIT
+ progress Three commits down, 1 to go!
+ commit refs/heads/O4
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ zcommits
+ COMMIT
+ progress done!
+ INPUT_END
+ git fast-import <input >actual &&
+ grep "progress " <input >expect &&
+ test_cmp expect actual
+'
###
### series P (gitlinks)
###
-cat >input <<INPUT_END
-blob
-mark :1
-data 10
-test file
-
-reset refs/heads/sub
-commit refs/heads/sub
-mark :2
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data 12
-sub_initial
-M 100644 :1 file
-
-blob
-mark :3
-data <<DATAEND
-[submodule "sub"]
- path = sub
- url = "`pwd`/sub"
-DATAEND
-
-commit refs/heads/subuse1
-mark :4
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data 8
-initial
-from refs/heads/master
-M 100644 :3 .gitmodules
-M 160000 :2 sub
-
-blob
-mark :5
-data 20
-test file
-more data
-
-commit refs/heads/sub
-mark :6
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data 11
-sub_second
-from :2
-M 100644 :5 file
-
-commit refs/heads/subuse1
-mark :7
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data 7
-second
-from :4
-M 160000 :6 sub
-
-INPUT_END
-
-test_expect_success \
- 'P: superproject & submodule mix' \
- 'git fast-import <input &&
- git checkout subuse1 &&
- rm -rf sub && mkdir sub && (cd sub &&
- git init &&
- git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
- git checkout master) &&
- git submodule init &&
- git submodule update'
-
-SUBLAST=$(git rev-parse --verify sub)
-SUBPREV=$(git rev-parse --verify sub^)
-
-cat >input <<INPUT_END
-blob
-mark :1
-data <<DATAEND
-[submodule "sub"]
- path = sub
- url = "`pwd`/sub"
-DATAEND
-
-commit refs/heads/subuse2
-mark :2
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data 8
-initial
-from refs/heads/master
-M 100644 :1 .gitmodules
-M 160000 $SUBPREV sub
-
-commit refs/heads/subuse2
-mark :3
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data 7
-second
-from :2
-M 160000 $SUBLAST sub
-
-INPUT_END
-
-test_expect_success \
- 'P: verbatim SHA gitlinks' \
- 'git branch -D sub &&
- git gc && git prune &&
- git fast-import <input &&
- test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
-
-test_tick
-cat >input <<INPUT_END
-commit refs/heads/subuse3
-mark :1
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-corrupt
-COMMIT
-
-from refs/heads/subuse2
-M 160000 inline sub
-data <<DATA
-$SUBPREV
-DATA
-
-INPUT_END
+test_expect_success 'P: superproject & submodule mix' '
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data 10
+ test file
-test_expect_success 'P: fail on inline gitlink' '
- test_must_fail git fast-import <input'
+ reset refs/heads/sub
+ commit refs/heads/sub
+ mark :2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data 12
+ sub_initial
+ M 100644 :1 file
+
+ blob
+ mark :3
+ data <<DATAEND
+ [submodule "sub"]
+ path = sub
+ url = "`pwd`/sub"
+ DATAEND
+
+ commit refs/heads/subuse1
+ mark :4
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data 8
+ initial
+ from refs/heads/master
+ M 100644 :3 .gitmodules
+ M 160000 :2 sub
+
+ blob
+ mark :5
+ data 20
+ test file
+ more data
+
+ commit refs/heads/sub
+ mark :6
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data 11
+ sub_second
+ from :2
+ M 100644 :5 file
+
+ commit refs/heads/subuse1
+ mark :7
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data 7
+ second
+ from :4
+ M 160000 :6 sub
+
+ INPUT_END
+
+ git fast-import <input &&
+ git checkout subuse1 &&
+ rm -rf sub &&
+ mkdir sub &&
+ (
+ cd sub &&
+ git init &&
+ git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
+ git checkout master
+ ) &&
+ git submodule init &&
+ git submodule update
+'
-test_tick
-cat >input <<INPUT_END
-blob
-mark :1
-data <<DATA
-$SUBPREV
-DATA
+test_expect_success 'P: verbatim SHA gitlinks' '
+ SUBLAST=$(git rev-parse --verify sub) &&
+ SUBPREV=$(git rev-parse --verify sub^) &&
-commit refs/heads/subuse3
-mark :2
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-corrupt
-COMMIT
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<DATAEND
+ [submodule "sub"]
+ path = sub
+ url = "`pwd`/sub"
+ DATAEND
-from refs/heads/subuse2
-M 160000 :1 sub
+ commit refs/heads/subuse2
+ mark :2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data 8
+ initial
+ from refs/heads/master
+ M 100644 :1 .gitmodules
+ M 160000 $SUBPREV sub
-INPUT_END
+ commit refs/heads/subuse2
+ mark :3
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data 7
+ second
+ from :2
+ M 160000 $SUBLAST sub
+
+ INPUT_END
+
+ git branch -D sub &&
+ git gc &&
+ git prune &&
+ git fast-import <input &&
+ test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
+'
+
+test_expect_success 'P: fail on inline gitlink' '
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/subuse3
+ mark :1
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ corrupt
+ COMMIT
+
+ from refs/heads/subuse2
+ M 160000 inline sub
+ data <<DATA
+ $SUBPREV
+ DATA
+
+ INPUT_END
+
+ test_must_fail git fast-import <input
+'
test_expect_success 'P: fail on blob mark in gitlink' '
- test_must_fail git fast-import <input'
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ blob
+ mark :1
+ data <<DATA
+ $SUBPREV
+ DATA
+
+ commit refs/heads/subuse3
+ mark :2
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ corrupt
+ COMMIT
+
+ from refs/heads/subuse2
+ M 160000 :1 sub
+
+ INPUT_END
+
+ test_must_fail git fast-import <input
+'
###
### series Q (notes)
###
-note1_data="The first note for the first commit"
-note2_data="The first note for the second commit"
-note3_data="The first note for the third commit"
-note1b_data="The second note for the first commit"
-note1c_data="The third note for the first commit"
-note2b_data="The second note for the second commit"
-
-test_tick
-cat >input <<INPUT_END
-blob
-mark :2
-data <<EOF
-$file2_data
-EOF
-
-commit refs/heads/notes-test
-mark :3
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-first (:3)
-COMMIT
-
-M 644 :2 file2
-
-blob
-mark :4
-data $file4_len
-$file4_data
-commit refs/heads/notes-test
-mark :5
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-second (:5)
-COMMIT
-
-M 644 :4 file4
-
-commit refs/heads/notes-test
-mark :6
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-third (:6)
-COMMIT
-
-M 644 inline file5
-data <<EOF
-$file5_data
-EOF
-
-M 755 inline file6
-data <<EOF
-$file6_data
-EOF
-
-blob
-mark :7
-data <<EOF
-$note1_data
-EOF
-
-blob
-mark :8
-data <<EOF
-$note2_data
-EOF
-
-commit refs/notes/foobar
-mark :9
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-notes (:9)
-COMMIT
-
-N :7 :3
-N :8 :5
-N inline :6
-data <<EOF
-$note3_data
-EOF
-
-commit refs/notes/foobar
-mark :10
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-notes (:10)
-COMMIT
-
-N inline :3
-data <<EOF
-$note1b_data
-EOF
-
-commit refs/notes/foobar2
-mark :11
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-notes (:11)
-COMMIT
-
-N inline :3
-data <<EOF
-$note1c_data
-EOF
-
-commit refs/notes/foobar
-mark :12
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-notes (:12)
-COMMIT
-
-deleteall
-N inline :5
-data <<EOF
-$note2b_data
-EOF
-
-INPUT_END
-
-test_expect_success \
- 'Q: commit notes' \
- 'git fast-import <input &&
- git whatchanged notes-test'
+test_expect_success 'Q: commit notes' '
+ note1_data="The first note for the first commit" &&
+ note2_data="The first note for the second commit" &&
+ note3_data="The first note for the third commit" &&
+ note1b_data="The second note for the first commit" &&
+ note1c_data="The third note for the first commit" &&
+ note2b_data="The second note for the second commit" &&
+
+ test_tick &&
+ cat >input <<-INPUT_END &&
+ blob
+ mark :2
+ data <<EOF
+ $file2_data
+ EOF
+
+ commit refs/heads/notes-test
+ mark :3
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ first (:3)
+ COMMIT
+
+ M 644 :2 file2
+
+ blob
+ mark :4
+ data $file4_len
+ $file4_data
+ commit refs/heads/notes-test
+ mark :5
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ second (:5)
+ COMMIT
+
+ M 644 :4 file4
+
+ commit refs/heads/notes-test
+ mark :6
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ third (:6)
+ COMMIT
+
+ M 644 inline file5
+ data <<EOF
+ $file5_data
+ EOF
+
+ M 755 inline file6
+ data <<EOF
+ $file6_data
+ EOF
+
+ blob
+ mark :7
+ data <<EOF
+ $note1_data
+ EOF
+
+ blob
+ mark :8
+ data <<EOF
+ $note2_data
+ EOF
+
+ commit refs/notes/foobar
+ mark :9
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:9)
+ COMMIT
+
+ N :7 :3
+ N :8 :5
+ N inline :6
+ data <<EOF
+ $note3_data
+ EOF
+
+ commit refs/notes/foobar
+ mark :10
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:10)
+ COMMIT
+
+ N inline :3
+ data <<EOF
+ $note1b_data
+ EOF
+
+ commit refs/notes/foobar2
+ mark :11
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:11)
+ COMMIT
+
+ N inline :3
+ data <<EOF
+ $note1c_data
+ EOF
+
+ commit refs/notes/foobar
+ mark :12
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ notes (:12)
+ COMMIT
+
+ deleteall
+ N inline :5
+ data <<EOF
+ $note2b_data
+ EOF
+
+ INPUT_END
+
+ git fast-import <input &&
+ git whatchanged notes-test
+'
test_expect_success 'Q: verify pack' '
verify_packs
'
-commit1=$(git rev-parse notes-test~2)
-commit2=$(git rev-parse notes-test^)
-commit3=$(git rev-parse notes-test)
-
-cat >expect <<EOF
-author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-
-first (:3)
-EOF
-test_expect_success \
- 'Q: verify first commit' \
- 'git cat-file commit notes-test~2 | sed 1d >actual &&
- test_cmp expect actual'
-
-cat >expect <<EOF
-parent $commit1
-author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-
-second (:5)
-EOF
-test_expect_success \
- 'Q: verify second commit' \
- 'git cat-file commit notes-test^ | sed 1d >actual &&
- test_cmp expect actual'
-
-cat >expect <<EOF
-parent $commit2
-author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-
-third (:6)
-EOF
-test_expect_success \
- 'Q: verify third commit' \
- 'git cat-file commit notes-test | sed 1d >actual &&
- test_cmp expect actual'
-
-cat >expect <<EOF
-author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-
-notes (:9)
-EOF
-test_expect_success \
- 'Q: verify first notes commit' \
- 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
- test_cmp expect actual'
-
-cat >expect.unsorted <<EOF
-100644 blob $commit1
-100644 blob $commit2
-100644 blob $commit3
-EOF
-cat expect.unsorted | sort >expect
-test_expect_success \
- 'Q: verify first notes tree' \
- 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
- test_cmp expect actual'
-
-echo "$note1_data" >expect
-test_expect_success \
- 'Q: verify first note for first commit' \
- 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
-
-echo "$note2_data" >expect
-test_expect_success \
- 'Q: verify first note for second commit' \
- 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
-
-echo "$note3_data" >expect
-test_expect_success \
- 'Q: verify first note for third commit' \
- 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
-
-cat >expect <<EOF
-parent `git rev-parse --verify refs/notes/foobar~2`
-author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-
-notes (:10)
-EOF
-test_expect_success \
- 'Q: verify second notes commit' \
- 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
- test_cmp expect actual'
-
-cat >expect.unsorted <<EOF
-100644 blob $commit1
-100644 blob $commit2
-100644 blob $commit3
-EOF
-cat expect.unsorted | sort >expect
-test_expect_success \
- 'Q: verify second notes tree' \
- 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
- test_cmp expect actual'
-
-echo "$note1b_data" >expect
-test_expect_success \
- 'Q: verify second note for first commit' \
- 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
-
-echo "$note2_data" >expect
-test_expect_success \
- 'Q: verify first note for second commit' \
- 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
-
-echo "$note3_data" >expect
-test_expect_success \
- 'Q: verify first note for third commit' \
- 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
-
-cat >expect <<EOF
-author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-
-notes (:11)
-EOF
-test_expect_success \
- 'Q: verify third notes commit' \
- 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
- test_cmp expect actual'
-
-cat >expect.unsorted <<EOF
-100644 blob $commit1
-EOF
-cat expect.unsorted | sort >expect
-test_expect_success \
- 'Q: verify third notes tree' \
- 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
- test_cmp expect actual'
-
-echo "$note1c_data" >expect
-test_expect_success \
- 'Q: verify third note for first commit' \
- 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
-
-cat >expect <<EOF
-parent `git rev-parse --verify refs/notes/foobar^`
-author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-
-notes (:12)
-EOF
-test_expect_success \
- 'Q: verify fourth notes commit' \
- 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
- test_cmp expect actual'
-
-cat >expect.unsorted <<EOF
-100644 blob $commit2
-EOF
-cat expect.unsorted | sort >expect
-test_expect_success \
- 'Q: verify fourth notes tree' \
- 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
- test_cmp expect actual'
-
-echo "$note2b_data" >expect
-test_expect_success \
- 'Q: verify second note for second commit' \
- 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
-
-cat >input <<EOF
-reset refs/heads/Q0
-
-commit refs/heads/note-Q0
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-Note for an empty branch.
-COMMIT
-
-N inline refs/heads/Q0
-data <<NOTE
-some note
-NOTE
-EOF
-test_expect_success \
- 'Q: deny note on empty branch' \
- 'test_must_fail git fast-import <input'
+test_expect_success 'Q: verify first commit' '
+ commit1=$(git rev-parse notes-test~2) &&
+ commit2=$(git rev-parse notes-test^) &&
+ commit3=$(git rev-parse notes-test) &&
+
+ cat >expect <<-EOF &&
+ author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+ first (:3)
+ EOF
+ git cat-file commit notes-test~2 | sed 1d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify second commit' '
+ cat >expect <<-EOF &&
+ parent $commit1
+ author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+ second (:5)
+ EOF
+ git cat-file commit notes-test^ | sed 1d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify third commit' '
+ cat >expect <<-EOF &&
+ parent $commit2
+ author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+ third (:6)
+ EOF
+ git cat-file commit notes-test | sed 1d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify first notes commit' '
+ cat >expect <<-EOF &&
+ author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+ notes (:9)
+ EOF
+ git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify first notes tree' '
+ cat >expect.unsorted <<-EOF &&
+ 100644 blob $commit1
+ 100644 blob $commit2
+ 100644 blob $commit3
+ EOF
+ cat expect.unsorted | sort >expect &&
+ git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify first note for first commit' '
+ echo "$note1_data" >expect &&
+ git cat-file blob refs/notes/foobar~2:$commit1 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify first note for second commit' '
+ echo "$note2_data" >expect &&
+ git cat-file blob refs/notes/foobar~2:$commit2 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify first note for third commit' '
+ echo "$note3_data" >expect &&
+ git cat-file blob refs/notes/foobar~2:$commit3 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify second notes commit' '
+ cat >expect <<-EOF &&
+ parent `git rev-parse --verify refs/notes/foobar~2`
+ author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+ notes (:10)
+ EOF
+ git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify second notes tree' '
+ cat >expect.unsorted <<-EOF &&
+ 100644 blob $commit1
+ 100644 blob $commit2
+ 100644 blob $commit3
+ EOF
+ cat expect.unsorted | sort >expect &&
+ git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify second note for first commit' '
+ echo "$note1b_data" >expect &&
+ git cat-file blob refs/notes/foobar^:$commit1 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify first note for second commit' '
+ echo "$note2_data" >expect &&
+ git cat-file blob refs/notes/foobar^:$commit2 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify first note for third commit' '
+ echo "$note3_data" >expect &&
+ git cat-file blob refs/notes/foobar^:$commit3 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify third notes commit' '
+ cat >expect <<-EOF &&
+ author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+ notes (:11)
+ EOF
+ git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify third notes tree' '
+ cat >expect.unsorted <<-EOF &&
+ 100644 blob $commit1
+ EOF
+ cat expect.unsorted | sort >expect &&
+ git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify third note for first commit' '
+ echo "$note1c_data" >expect &&
+ git cat-file blob refs/notes/foobar2:$commit1 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify fourth notes commit' '
+ cat >expect <<-EOF &&
+ parent `git rev-parse --verify refs/notes/foobar^`
+ author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+ notes (:12)
+ EOF
+ git cat-file commit refs/notes/foobar | sed 1d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify fourth notes tree' '
+ cat >expect.unsorted <<-EOF &&
+ 100644 blob $commit2
+ EOF
+ cat expect.unsorted | sort >expect &&
+ git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: verify second note for second commit' '
+ echo "$note2b_data" >expect &&
+ git cat-file blob refs/notes/foobar:$commit2 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Q: deny note on empty branch' '
+ cat >input <<-EOF &&
+ reset refs/heads/Q0
+
+ commit refs/heads/note-Q0
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ Note for an empty branch.
+ COMMIT
+
+ N inline refs/heads/Q0
+ data <<NOTE
+ some note
+ NOTE
+ EOF
+ test_must_fail git fast-import <input
+'
###
### series R (feature and option)
###
-cat >input <<EOF
-feature no-such-feature-exists
-EOF
-
test_expect_success 'R: abort on unsupported feature' '
+ cat >input <<-EOF &&
+ feature no-such-feature-exists
+ EOF
+
test_must_fail git fast-import <input
'
-cat >input <<EOF
-feature date-format=now
-EOF
-
test_expect_success 'R: supported feature is accepted' '
+ cat >input <<-EOF &&
+ feature date-format=now
+ EOF
+
git fast-import <input
'
-cat >input << EOF
-blob
-data 3
-hi
-feature date-format=now
-EOF
-
test_expect_success 'R: abort on receiving feature after data command' '
+ cat >input <<-EOF &&
+ blob
+ data 3
+ hi
+ feature date-format=now
+ EOF
+
test_must_fail git fast-import <input
'
-cat >input << EOF
-feature import-marks=git.marks
-feature import-marks=git2.marks
-EOF
-
test_expect_success 'R: only one import-marks feature allowed per stream' '
+ cat >input <<-EOF &&
+ feature import-marks=git.marks
+ feature import-marks=git2.marks
+ EOF
+
test_must_fail git fast-import <input
'
-cat >input << EOF
-feature export-marks=git.marks
-blob
-mark :1
-data 3
-hi
+test_expect_success 'R: export-marks feature results in a marks file being created' '
+ cat >input <<-EOF &&
+ feature export-marks=git.marks
+ blob
+ mark :1
+ data 3
+ hi
-EOF
+ EOF
-test_expect_success \
- 'R: export-marks feature results in a marks file being created' \
- 'cat input | git fast-import &&
- grep :1 git.marks'
+ cat input | git fast-import &&
+ grep :1 git.marks
+'
-test_expect_success \
- 'R: export-marks options can be overridden by commandline options' \
- 'cat input | git fast-import --export-marks=other.marks &&
- grep :1 other.marks'
+test_expect_success 'R: export-marks options can be overridden by commandline options' '
+ cat input | git fast-import --export-marks=other.marks &&
+ grep :1 other.marks
+'
test_expect_success 'R: catch typo in marks file name' '
test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
@@ -2234,62 +2248,62 @@ test_expect_success 'R: feature import-marks-if-exists' '
test_cmp expect io.marks
'
-cat >input << EOF
-feature import-marks=marks.out
-feature export-marks=marks.new
-EOF
-
-test_expect_success \
- 'R: import to output marks works without any content' \
- 'cat input | git fast-import &&
- test_cmp marks.out marks.new'
+test_expect_success 'R: import to output marks works without any content' '
+ cat >input <<-EOF &&
+ feature import-marks=marks.out
+ feature export-marks=marks.new
+ EOF
-cat >input <<EOF
-feature import-marks=nonexistent.marks
-feature export-marks=marks.new
-EOF
+ cat input | git fast-import &&
+ test_cmp marks.out marks.new
+'
-test_expect_success \
- 'R: import marks prefers commandline marks file over the stream' \
- 'cat input | git fast-import --import-marks=marks.out &&
- test_cmp marks.out marks.new'
+test_expect_success 'R: import marks prefers commandline marks file over the stream' '
+ cat >input <<-EOF &&
+ feature import-marks=nonexistent.marks
+ feature export-marks=marks.new
+ EOF
+ cat input | git fast-import --import-marks=marks.out &&
+ test_cmp marks.out marks.new
+'
-cat >input <<EOF
-feature import-marks=nonexistent.marks
-feature export-marks=combined.marks
-EOF
test_expect_success 'R: multiple --import-marks= should be honoured' '
- head -n2 marks.out > one.marks &&
- tail -n +3 marks.out > two.marks &&
- git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
- test_cmp marks.out combined.marks
-'
+ cat >input <<-EOF &&
+ feature import-marks=nonexistent.marks
+ feature export-marks=combined.marks
+ EOF
-cat >input <<EOF
-feature relative-marks
-feature import-marks=relative.in
-feature export-marks=relative.out
-EOF
+ head -n2 marks.out > one.marks &&
+ tail -n +3 marks.out > two.marks &&
+ git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
+ test_cmp marks.out combined.marks
+'
test_expect_success 'R: feature relative-marks should be honoured' '
- mkdir -p .git/info/fast-import/ &&
- cp marks.new .git/info/fast-import/relative.in &&
- git fast-import <input &&
- test_cmp marks.new .git/info/fast-import/relative.out
-'
+ cat >input <<-EOF &&
+ feature relative-marks
+ feature import-marks=relative.in
+ feature export-marks=relative.out
+ EOF
-cat >input <<EOF
-feature relative-marks
-feature import-marks=relative.in
-feature no-relative-marks
-feature export-marks=non-relative.out
-EOF
+ mkdir -p .git/info/fast-import/ &&
+ cp marks.new .git/info/fast-import/relative.in &&
+ git fast-import <input &&
+ test_cmp marks.new .git/info/fast-import/relative.out
+'
test_expect_success 'R: feature no-relative-marks should be honoured' '
- git fast-import <input &&
- test_cmp marks.new non-relative.out
+ cat >input <<-EOF &&
+ feature relative-marks
+ feature import-marks=relative.in
+ feature no-relative-marks
+ feature export-marks=non-relative.out
+ EOF
+
+ git fast-import <input &&
+ test_cmp marks.new non-relative.out
'
test_expect_success 'R: feature ls supported' '
@@ -2330,12 +2344,12 @@ test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
cat-blob $blob
EOF
test_cmp expect actual.3 &&
- test_cmp empty actual.1 &&
+ test_must_be_empty actual.1 &&
git fast-import 3>actual.3 >actual.1 <<-EOF &&
option cat-blob-fd=3
cat-blob $blob
EOF
- test_cmp empty actual.3 &&
+ test_must_be_empty actual.3 &&
test_cmp expect actual.1
'
@@ -2549,17 +2563,17 @@ test_expect_success PIPE 'R: print staged blob within commit' '
test_cmp expect actual
'
-cat >input << EOF
-option git quiet
-blob
-data 3
-hi
+test_expect_success 'R: quiet option results in no stats being output' '
+ cat >input <<-EOF &&
+ option git quiet
+ blob
+ data 3
+ hi
-EOF
+ EOF
-test_expect_success 'R: quiet option results in no stats being output' '
- cat input | git fast-import 2> output &&
- test_cmp empty output
+ cat input | git fast-import 2> output &&
+ test_must_be_empty output
'
test_expect_success 'R: feature done means terminating "done" is mandatory' '
@@ -2604,16 +2618,16 @@ test_expect_success 'R: terminating "done" within commit' '
test_cmp expect actual
'
-cat >input <<EOF
-option git non-existing-option
-EOF
-
test_expect_success 'R: die on unknown option' '
- test_must_fail git fast-import <input
+ cat >input <<-EOF &&
+ option git non-existing-option
+ EOF
+
+ test_must_fail git fast-import <input
'
test_expect_success 'R: unknown commandline options are rejected' '\
- test_must_fail git fast-import --non-existing-option < /dev/null
+ test_must_fail git fast-import --non-existing-option < /dev/null
'
test_expect_success 'R: die on invalid option argument' '
@@ -2624,41 +2638,41 @@ test_expect_success 'R: die on invalid option argument' '
test_must_fail git fast-import --depth="5 elephants" </dev/null
'
-cat >input <<EOF
-option non-existing-vcs non-existing-option
-EOF
-
test_expect_success 'R: ignore non-git options' '
- git fast-import <input
+ cat >input <<-EOF &&
+ option non-existing-vcs non-existing-option
+ EOF
+
+ git fast-import <input
'
##
## R: very large blobs
##
-blobsize=$((2*1024*1024 + 53))
-test-genrandom bar $blobsize >expect
-cat >input <<INPUT_END
-commit refs/heads/big-file
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-R - big file
-COMMIT
-
-M 644 inline big1
-data $blobsize
-INPUT_END
-cat expect >>input
-cat >>input <<INPUT_END
-M 644 inline big2
-data $blobsize
-INPUT_END
-cat expect >>input
-echo >>input
-
-test_expect_success \
- 'R: blob bigger than threshold' \
- 'test_create_repo R &&
- git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
+test_expect_success 'R: blob bigger than threshold' '
+ blobsize=$((2*1024*1024 + 53)) &&
+ test-genrandom bar $blobsize >expect &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/big-file
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ R - big file
+ COMMIT
+
+ M 644 inline big1
+ data $blobsize
+ INPUT_END
+ cat expect >>input &&
+ cat >>input <<-INPUT_END &&
+ M 644 inline big2
+ data $blobsize
+ INPUT_END
+ cat expect >>input &&
+ echo >>input &&
+
+ test_create_repo R &&
+ git --git-dir=R/.git fast-import --big-file-threshold=1 <input
+'
test_expect_success 'R: verify created pack' '
(
@@ -2667,17 +2681,18 @@ test_expect_success 'R: verify created pack' '
)
'
-test_expect_success \
- 'R: verify written objects' \
- 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
- test_cmp_bin expect actual &&
- a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
- b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
- test $a = $b'
-test_expect_success \
- 'R: blob appears only once' \
- 'n=$(grep $a verify | wc -l) &&
- test 1 = $n'
+test_expect_success 'R: verify written objects' '
+ git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
+ test_cmp_bin expect actual &&
+ a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
+ b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
+ test $a = $b
+'
+
+test_expect_success 'R: blob appears only once' '
+ n=$(grep $a verify | wc -l) &&
+ test 1 = $n
+'
###
### series S
@@ -2710,46 +2725,46 @@ test_expect_success \
#
# Invalid dataref ..
#
-test_tick
-
-cat >input <<INPUT_END
-commit refs/heads/S
-mark :301
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-commit 1
-COMMIT
-M 100644 inline hello.c
-data <<BLOB
-blob 1
-BLOB
-
-commit refs/heads/S
-mark :302
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-commit 2
-COMMIT
-from :301
-M 100644 inline hello.c
-data <<BLOB
-blob 2
-BLOB
-
-blob
-mark :403
-data <<BLOB
-blob 3
-BLOB
-
-blob
-mark :202
-data <<BLOB
-note 2
-BLOB
-INPUT_END
-
test_expect_success 'S: initialize for S tests' '
+ test_tick &&
+
+ cat >input <<-INPUT_END &&
+ commit refs/heads/S
+ mark :301
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit 1
+ COMMIT
+ M 100644 inline hello.c
+ data <<BLOB
+ blob 1
+ BLOB
+
+ commit refs/heads/S
+ mark :302
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ commit 2
+ COMMIT
+ from :301
+ M 100644 inline hello.c
+ data <<BLOB
+ blob 2
+ BLOB
+
+ blob
+ mark :403
+ data <<BLOB
+ blob 3
+ BLOB
+
+ blob
+ mark :202
+ data <<BLOB
+ note 2
+ BLOB
+ INPUT_END
+
git fast-import --export-marks=marks <input
'
@@ -3001,103 +3016,103 @@ test_expect_success 'T: empty reset doesnt delete branch' '
### series U (filedelete)
###
-cat >input <<INPUT_END
-commit refs/heads/U
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-test setup
-COMMIT
-M 100644 inline hello.c
-data <<BLOB
-blob 1
-BLOB
-M 100644 inline good/night.txt
-data <<BLOB
-sleep well
-BLOB
-M 100644 inline good/bye.txt
-data <<BLOB
-au revoir
-BLOB
-
-INPUT_END
-
test_expect_success 'U: initialize for U tests' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/U
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ test setup
+ COMMIT
+ M 100644 inline hello.c
+ data <<BLOB
+ blob 1
+ BLOB
+ M 100644 inline good/night.txt
+ data <<BLOB
+ sleep well
+ BLOB
+ M 100644 inline good/bye.txt
+ data <<BLOB
+ au revoir
+ BLOB
+
+ INPUT_END
+
git fast-import <input
'
-cat >input <<INPUT_END
-commit refs/heads/U
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-delete good/night.txt
-COMMIT
-from refs/heads/U^0
-D good/night.txt
+test_expect_success 'U: filedelete file succeeds' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/U
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ delete good/night.txt
+ COMMIT
+ from refs/heads/U^0
+ D good/night.txt
-INPUT_END
+ INPUT_END
-test_expect_success 'U: filedelete file succeeds' '
git fast-import <input
'
-cat >expect <<EOF
-:100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
-EOF
+test_expect_success 'U: validate file delete result' '
+ cat >expect <<-EOF &&
+ :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
+ EOF
-git diff-tree -M -r U^1 U >actual
+ git diff-tree -M -r U^1 U >actual &&
-test_expect_success 'U: validate file delete result' '
compare_diff_raw expect actual
'
-cat >input <<INPUT_END
-commit refs/heads/U
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-delete good dir
-COMMIT
-from refs/heads/U^0
-D good
+test_expect_success 'U: filedelete directory succeeds' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/U
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ delete good dir
+ COMMIT
+ from refs/heads/U^0
+ D good
-INPUT_END
+ INPUT_END
-test_expect_success 'U: filedelete directory succeeds' '
git fast-import <input
'
-cat >expect <<EOF
-:100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
-EOF
+test_expect_success 'U: validate directory delete result' '
+ cat >expect <<-EOF &&
+ :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
+ EOF
-git diff-tree -M -r U^1 U >actual
+ git diff-tree -M -r U^1 U >actual &&
-test_expect_success 'U: validate directory delete result' '
compare_diff_raw expect actual
'
-cat >input <<INPUT_END
-commit refs/heads/U
-committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-data <<COMMIT
-must succeed
-COMMIT
-from refs/heads/U^0
-D ""
+test_expect_success 'U: filedelete root succeeds' '
+ cat >input <<-INPUT_END &&
+ commit refs/heads/U
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ must succeed
+ COMMIT
+ from refs/heads/U^0
+ D ""
-INPUT_END
+ INPUT_END
-test_expect_success 'U: filedelete root succeeds' '
- git fast-import <input
+ git fast-import <input
'
-cat >expect <<EOF
-:100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
-EOF
+test_expect_success 'U: validate root delete result' '
+ cat >expect <<-EOF &&
+ :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
+ EOF
-git diff-tree -M -r U^1 U >actual
+ git diff-tree -M -r U^1 U >actual &&
-test_expect_success 'U: validate root delete result' '
compare_diff_raw expect actual
'
diff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh
index 90d41ed..0730f18 100755
--- a/t/t9800-git-p4-basic.sh
+++ b/t/t9800-git-p4-basic.sh
@@ -241,6 +241,22 @@ test_expect_success 'unresolvable host in P4PORT should display error' '
)
'
+test_expect_success 'submit from detached head' '
+ test_when_finished cleanup_git &&
+ git p4 clone --dest="$git" //depot &&
+ (
+ cd "$git" &&
+ git checkout p4/master &&
+ >detached_head_test &&
+ git add detached_head_test &&
+ git commit -m "add detached_head" &&
+ git config git-p4.skipSubmitEdit true &&
+ git p4 submit &&
+ git p4 rebase &&
+ git log p4/master | grep detached_head
+ )
+'
+
test_expect_success 'kill p4d' '
kill_p4d
'
diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh
index 1f74a88..5931528 100755
--- a/t/t9807-git-p4-submit.sh
+++ b/t/t9807-git-p4-submit.sh
@@ -389,7 +389,7 @@ test_expect_success 'description with Jobs section and bogus following text' '
(
cd "$cli" &&
p4 revert desc6 &&
- rm desc6
+ rm -f desc6
)
'
diff --git a/transport.c b/transport.c
index 23b2ed6..e34ab92 100644
--- a/transport.c
+++ b/transport.c
@@ -15,6 +15,7 @@
#include "submodule.h"
#include "string-list.h"
#include "sha1-array.h"
+#include "sigchain.h"
/* rsync support */
@@ -1127,6 +1128,8 @@ static int run_pre_push_hook(struct transport *transport,
return -1;
}
+ sigchain_push(SIGPIPE, SIG_IGN);
+
strbuf_init(&buf, 256);
for (r = remote_refs; r; r = r->next) {
@@ -1140,8 +1143,10 @@ static int run_pre_push_hook(struct transport *transport,
r->peer_ref->name, sha1_to_hex(r->new_sha1),
r->name, sha1_to_hex(r->old_sha1));
- if (write_in_full(proc.in, buf.buf, buf.len) != buf.len) {
- ret = -1;
+ if (write_in_full(proc.in, buf.buf, buf.len) < 0) {
+ /* We do not mind if a hook does not read all refs. */
+ if (errno != EPIPE)
+ ret = -1;
break;
}
}
@@ -1152,6 +1157,8 @@ static int run_pre_push_hook(struct transport *transport,
if (!ret)
ret = x;
+ sigchain_pop(SIGPIPE);
+
x = finish_command(&proc);
if (!ret)
ret = x;