diff options
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | builtin-add.c | 3 | ||||
-rw-r--r-- | builtin-grep.c | 2 | ||||
-rw-r--r-- | builtin-merge.c | 7 | ||||
-rw-r--r-- | builtin-push.c | 29 | ||||
-rw-r--r-- | builtin-reset.c | 2 | ||||
-rw-r--r-- | cache.h | 3 | ||||
-rwxr-xr-x | git-svn.perl | 2 | ||||
-rw-r--r-- | read-cache.c | 5 | ||||
-rwxr-xr-x | t/t2103-update-index-ignore-missing.sh | 89 | ||||
-rwxr-xr-x | t/t7102-reset.sh | 2 | ||||
-rwxr-xr-x | t/t7600-merge.sh | 2 | ||||
-rwxr-xr-x | t/t9400-git-cvsserver-server.sh | 7 | ||||
-rw-r--r-- | wrapper.c | 38 | ||||
-rw-r--r-- | write_or_die.c | 38 |
15 files changed, 165 insertions, 74 deletions
@@ -324,6 +324,7 @@ endif export PERL_PATH LIB_FILE=libgit.a +COMPAT_LIB = compat/lib.a XDIFF_LIB=xdiff/lib.a LIB_H += archive.h @@ -1203,8 +1204,11 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) -git-shell$X: compat/strlcpy.o abspath.o ctype.o exec_cmd.o quote.o strbuf.o usage.o wrapper.o shell.o - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) +$(COMPAT_LIB): $(COMPAT_OBJS) + $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(COMPAT_OBJS) + +git-shell$X: abspath.o ctype.o exec_cmd.o quote.o strbuf.o usage.o wrapper.o shell.o $(COMPAT_LIB) + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(COMPAT_LIB) $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H) $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h) @@ -1402,7 +1406,7 @@ distclean: clean clean: $(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \ - $(LIB_FILE) $(XDIFF_LIB) + $(LIB_FILE) $(XDIFF_LIB) $(COMPAT_LIB) $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X $(RM) $(TEST_PROGRAMS) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope* diff --git a/builtin-add.c b/builtin-add.c index 6f5672a616..fc3f96eaef 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -140,7 +140,8 @@ static void refresh(int verbose, const char **pathspec) for (specs = 0; pathspec[specs]; specs++) /* nothing */; seen = xcalloc(specs, 1); - refresh_index(&the_index, verbose ? 0 : REFRESH_QUIET, pathspec, seen); + refresh_index(&the_index, verbose ? REFRESH_SAY_CHANGED : REFRESH_QUIET, + pathspec, seen); for (i = 0; i < specs; i++) { if (!seen[i]) die("pathspec '%s' did not match any files", pathspec[i]); diff --git a/builtin-grep.c b/builtin-grep.c index 7bf6a7156c..631129ddfd 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -498,7 +498,7 @@ static int grep_object(struct grep_opt *opt, const char **paths, } static const char builtin_grep_usage[] = -"git grep <option>* <rev>* [-e] <pattern> [<path>...]"; +"git grep <option>* [-e] <pattern> <rev>* [[--] <path>...]"; static const char emsg_invalid_context_len[] = "%s: invalid context length argument"; diff --git a/builtin-merge.c b/builtin-merge.c index 129b4e62dd..e97c79e60c 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -50,11 +50,9 @@ static size_t use_strategies_nr, use_strategies_alloc; static const char *branch; static struct strategy all_strategy[] = { - { "recur", NO_TRIVIAL }, { "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL }, { "octopus", DEFAULT_OCTOPUS }, { "resolve", 0 }, - { "stupid", 0 }, { "ours", NO_FAST_FORWARD | NO_TRIVIAL }, { "subtree", NO_FAST_FORWARD | NO_TRIVIAL }, }; @@ -68,10 +66,11 @@ static int option_parse_message(const struct option *opt, if (unset) strbuf_setlen(buf, 0); - else { + else if (arg) { strbuf_addf(buf, "%s\n\n", arg); have_message = 1; - } + } else + return error("switch `m' requires a value"); return 0; } diff --git a/builtin-push.c b/builtin-push.c index 03db28cc36..c1ed68d938 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -14,7 +14,7 @@ static const char * const push_usage[] = { NULL, }; -static int thin, verbose; +static int thin; static const char *receivepack; static const char **refspec; @@ -84,7 +84,7 @@ static int do_push(const char *repo, int flags) if (thin) transport_set_option(transport, TRANS_OPT_THIN, "yes"); - if (verbose) + if (flags & TRANSPORT_PUSH_VERBOSE) fprintf(stderr, "Pushing to %s\n", remote->url[i]); err = transport_push(transport, refspec_nr, refspec, flags); err |= transport_disconnect(transport); @@ -101,22 +101,19 @@ static int do_push(const char *repo, int flags) int cmd_push(int argc, const char **argv, const char *prefix) { int flags = 0; - int all = 0; - int mirror = 0; - int dry_run = 0; - int force = 0; int tags = 0; int rc; const char *repo = NULL; /* default repository */ struct option options[] = { - OPT__VERBOSE(&verbose), + OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE), OPT_STRING( 0 , "repo", &repo, "repository", "repository"), - OPT_BOOLEAN( 0 , "all", &all, "push all refs"), - OPT_BOOLEAN( 0 , "mirror", &mirror, "mirror all refs"), + OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL), + OPT_BIT( 0 , "mirror", &flags, "mirror all refs", + (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)), OPT_BOOLEAN( 0 , "tags", &tags, "push tags"), - OPT_BOOLEAN( 0 , "dry-run", &dry_run, "dry run"), - OPT_BOOLEAN('f', "force", &force, "force updates"), + OPT_BIT( 0 , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN), + OPT_BIT('f', "force", &flags, "force updates", TRANSPORT_PUSH_FORCE), OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"), OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", "receive pack program"), OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"), @@ -125,18 +122,8 @@ int cmd_push(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, options, push_usage, 0); - if (force) - flags |= TRANSPORT_PUSH_FORCE; - if (dry_run) - flags |= TRANSPORT_PUSH_DRY_RUN; - if (verbose) - flags |= TRANSPORT_PUSH_VERBOSE; if (tags) add_refspec("refs/tags/*"); - if (all) - flags |= TRANSPORT_PUSH_ALL; - if (mirror) - flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE); if (argc > 0) { repo = argv[0]; diff --git a/builtin-reset.c b/builtin-reset.c index 2e5a8867ac..4d246c31b1 100644 --- a/builtin-reset.c +++ b/builtin-reset.c @@ -96,7 +96,7 @@ static int update_index_refresh(int fd, struct lock_file *index_lock) if (read_cache() < 0) return error("Could not read index"); - result = refresh_cache(0) ? 1 : 0; + result = refresh_cache(REFRESH_SAY_CHANGED) ? 1 : 0; if (write_cache(fd, active_cache, active_nr) || commit_locked_index(index_lock)) return error ("Could not refresh index"); @@ -397,7 +397,8 @@ extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st); #define REFRESH_UNMERGED 0x0002 /* allow unmerged */ #define REFRESH_QUIET 0x0004 /* be quiet about it */ #define REFRESH_IGNORE_MISSING 0x0008 /* ignore non-existent */ -#define REFRESH_IGNORE_SUBMODULES 0x0008 /* ignore submodules */ +#define REFRESH_IGNORE_SUBMODULES 0x0010 /* ignore submodules */ +#define REFRESH_SAY_CHANGED 0x0020 /* say "changed" not "needs update" */ extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen); struct lock_file { diff --git a/git-svn.perl b/git-svn.perl index 28aeb03fdc..2e0e55242f 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1226,7 +1226,7 @@ sub linearize_history { sub find_file_type_and_diff_status { my ($path) = @_; - return ('dir', '') if $path eq '.'; + return ('dir', '') if $path eq ''; my $diff_output = command_oneline(qw(diff --cached --name-status --), $path) || ""; diff --git a/read-cache.c b/read-cache.c index 16484281f7..a50a851125 100644 --- a/read-cache.c +++ b/read-cache.c @@ -980,7 +980,10 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p int not_new = (flags & REFRESH_IGNORE_MISSING) != 0; int ignore_submodules = (flags & REFRESH_IGNORE_SUBMODULES) != 0; unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0; + const char *needs_update_message; + needs_update_message = ((flags & REFRESH_SAY_CHANGED) + ? "locally modified" : "needs update"); for (i = 0; i < istate->cache_nr; i++) { struct cache_entry *ce, *new; int cache_errno = 0; @@ -1019,7 +1022,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p } if (quiet) continue; - printf("%s: needs update\n", ce->name); + printf("%s: %s\n", ce->name, needs_update_message); has_errors = 1; continue; } diff --git a/t/t2103-update-index-ignore-missing.sh b/t/t2103-update-index-ignore-missing.sh new file mode 100755 index 0000000000..332694e7d3 --- /dev/null +++ b/t/t2103-update-index-ignore-missing.sh @@ -0,0 +1,89 @@ +#!/bin/sh + +test_description='update-index with options' + +. ./test-lib.sh + +test_expect_success basics ' + >one && + >two && + >three && + + # need --add when adding + test_must_fail git update-index one && + test -z "$(git ls-files)" && + git update-index --add one && + test zone = "z$(git ls-files)" && + + # update-index is atomic + echo 1 >one && + test_must_fail git update-index one two && + echo "M one" >expect && + git diff-files --name-status >actual && + test_cmp expect actual && + + git update-index --add one two three && + for i in one three two; do echo $i; done >expect && + git ls-files >actual && + test_cmp expect actual && + + test_tick && + ( + test_create_repo xyzzy && + cd xyzzy && + >file && + git add file + git commit -m "sub initial" + ) && + git add xyzzy && + + test_tick && + git commit -m initial && + git tag initial +' + +test_expect_success '--ignore-missing --refresh' ' + git reset --hard initial && + echo 2 >one && + test_must_fail git update-index --refresh && + echo 1 >one && + git update-index --refresh && + rm -f two && + test_must_fail git update-index --refresh && + git update-index --ignore-missing --refresh + +' + +test_expect_success '--unmerged --refresh' ' + git reset --hard initial && + info=$(git ls-files -s one | sed -e "s/ 0 / 1 /") && + git rm --cached one && + echo "$info" | git update-index --index-info && + test_must_fail git update-index --refresh && + git update-index --unmerged --refresh && + echo 2 >two && + test_must_fail git update-index --unmerged --refresh >actual && + grep two actual && + ! grep one actual && + ! grep three actual +' + +test_expect_success '--ignore-submodules --refresh (1)' ' + git reset --hard initial && + rm -f two && + test_must_fail git update-index --ignore-submodules --refresh +' + +test_expect_success '--ignore-submodules --refresh (2)' ' + git reset --hard initial && + test_tick && + ( + cd xyzzy && + git commit -m "sub second" --allow-empty + ) && + test_must_fail git update-index --refresh && + test_must_fail git update-index --ignore-missing --refresh && + git update-index --ignore-submodules --refresh +' + +test_done diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index 0bfc1e9be4..29f5678b4c 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -419,7 +419,7 @@ test_expect_success 'resetting an unmodified path is a no-op' ' ' cat > expect << EOF -file2: needs update +file2: locally modified EOF test_expect_success '--mixed refreshes the index' ' diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 26cf8dc7c1..5eeb6c2b27 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -221,7 +221,7 @@ test_expect_success 'setup' ' test_debug 'gitk --all' -test_expect_failure 'test option parsing' ' +test_expect_success 'test option parsing' ' test_must_fail git merge -$ c1 && test_must_fail git merge --no-such c1 && test_must_fail git merge -s foobar c1 && diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index d49f0df8c4..4b91f8d4c4 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -438,6 +438,13 @@ test_expect_success 'cvs update (-p)' ' test -z "$(cat failures)" ' +cd "$WORKDIR" +test_expect_success 'cvs update (module list supports packed refs)' ' + GIT_DIR="$SERVERDIR" git pack-refs --all && + GIT_CONFIG="$git_config" cvs -n up -d 2> out && + grep "cvs update: New directory \`master'\''" < out +' + #------------ # CVS STATUS #------------ @@ -133,6 +133,44 @@ ssize_t xwrite(int fd, const void *buf, size_t len) } } +ssize_t read_in_full(int fd, void *buf, size_t count) +{ + char *p = buf; + ssize_t total = 0; + + while (count > 0) { + ssize_t loaded = xread(fd, p, count); + if (loaded <= 0) + return total ? total : loaded; + count -= loaded; + p += loaded; + total += loaded; + } + + return total; +} + +ssize_t write_in_full(int fd, const void *buf, size_t count) +{ + const char *p = buf; + ssize_t total = 0; + + while (count > 0) { + ssize_t written = xwrite(fd, p, count); + if (written < 0) + return -1; + if (!written) { + errno = ENOSPC; + return -1; + } + count -= written; + p += written; + total += written; + } + + return total; +} + int xdup(int fd) { int ret = dup(fd); diff --git a/write_or_die.c b/write_or_die.c index e4c8e225fd..4c29255df1 100644 --- a/write_or_die.c +++ b/write_or_die.c @@ -45,44 +45,6 @@ void maybe_flush_or_die(FILE *f, const char *desc) } } -ssize_t read_in_full(int fd, void *buf, size_t count) -{ - char *p = buf; - ssize_t total = 0; - - while (count > 0) { - ssize_t loaded = xread(fd, p, count); - if (loaded <= 0) - return total ? total : loaded; - count -= loaded; - p += loaded; - total += loaded; - } - - return total; -} - -ssize_t write_in_full(int fd, const void *buf, size_t count) -{ - const char *p = buf; - ssize_t total = 0; - - while (count > 0) { - ssize_t written = xwrite(fd, p, count); - if (written < 0) - return -1; - if (!written) { - errno = ENOSPC; - return -1; - } - count -= written; - p += written; - total += written; - } - - return total; -} - void fsync_or_die(int fd, const char *msg) { if (fsync(fd) < 0) { |