From: Junio C Hamano Date: Thu, 28 Sep 2006 05:23:12 +0000 (-0700) Subject: Merge branch 'master' into lj/refs X-Git-Tag: v1.4.4-rc1~43^2~12 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2958d9b5dbebeb82e7230bbfd3f421781d90f3f7;p=git.git Merge branch 'master' into lj/refs * master: (72 commits) runstatus: do not recurse into subdirectories if not needed grep: fix --fixed-strings combined with expression. grep: free expressions and patterns when done. Corrected copy-and-paste thinko in ignore executable bit test case. An illustration of rev-list --parents --pretty=raw Allow git-checkout when on a non-existant branch. gitweb: Decode long title for link tooltips git-svn: Fix fetch --no-ignore-externals with GIT_SVN_NO_LIB=1 Ignore executable bit when adding files if filemode=0. Remove empty ref directories that prevent creating a ref. Use const for interpolate arguments git-archive: update documentation Deprecate merge-recursive.py gitweb: fix over-eager application of esc_html(). Allow '(no author)' in git-svn's authors file. Allow 'svn fetch' on '(no date)' revisions in Subversion. git-repack: allow git-repack to run in subdirectory Remove upload-tar and make git-tar-tree a thin wrapper to git-archive git-tar-tree: Move code for git-archive --format=tar to archive-tar.c git-tar-tree: Remove duplicate git_config() call ... --- 2958d9b5dbebeb82e7230bbfd3f421781d90f3f7 diff --cc Makefile index af4d68fd7,c888c810b..65fb8284f --- a/Makefile +++ b/Makefile @@@ -299,12 -298,8 +299,10 @@@ BUILTIN_OBJS = builtin-update-index.o \ builtin-update-ref.o \ builtin-upload-archive.o \ - builtin-upload-tar.o \ builtin-verify-pack.o \ - builtin-write-tree.o + builtin-write-tree.o \ - builtin-zip-tree.o \ + builtin-show-ref.o \ + builtin-pack-refs.o GITLIBS = $(LIB_FILE) $(XDIFF_LIB) LIBS = $(GITLIBS) -lz diff --cc git-branch.sh index 4379a0721,4f31903d6..bf84b3069 --- a/git-branch.sh +++ b/git-branch.sh @@@ -111,8 -112,17 +111,18 @@@ rev=$(git-rev-parse --verify "$head") | git-check-ref-format "heads/$branchname" || die "we do not like '$branchname' as a branch name." + if [ -d "$GIT_DIR/refs/heads/$branchname" ] + then + for refdir in `cd "$GIT_DIR" && \ + find "refs/heads/$branchname" -type d | sort -r` + do + rmdir "$GIT_DIR/$refdir" || \ + die "Could not delete '$refdir', there may still be a ref there." + done + fi + -if [ -e "$GIT_DIR/refs/heads/$branchname" ] +prev='' +if git-show-ref --verify --quiet -- "refs/heads/$branchname" then if test '' = "$force" then diff --cc receive-pack.c index c8aacbbdd,ea2dbd4e3..1fcf3a911 --- a/receive-pack.c +++ b/receive-pack.c @@@ -94,7 -129,50 +96,22 @@@ static int update(struct command *cmd return error("unpack should have generated %s, " "but I can't find it!", new_hex); } + if (deny_non_fast_forwards && !is_null_sha1(old_sha1)) { + struct commit *old_commit, *new_commit; + struct commit_list *bases, *ent; + + old_commit = (struct commit *)parse_object(old_sha1); + new_commit = (struct commit *)parse_object(new_sha1); + bases = get_merge_bases(old_commit, new_commit, 1); + for (ent = bases; ent; ent = ent->next) + if (!hashcmp(old_sha1, ent->item->object.sha1)) + break; + free_commit_list(bases); + if (!ent) + return error("denying non-fast forward;" + " you should pull first"); + } - safe_create_leading_directories(lock_name); - - newfd = open(lock_name, O_CREAT | O_EXCL | O_WRONLY, 0666); - if (newfd < 0) { - cmd->error_string = "can't lock"; - return error("unable to create %s (%s)", - lock_name, strerror(errno)); - } - - /* Write the ref with an ending '\n' */ - new_hex[40] = '\n'; - new_hex[41] = 0; - written = write(newfd, new_hex, 41); - /* Remove the '\n' again */ - new_hex[40] = 0; - - close(newfd); - if (written != 41) { - unlink(lock_name); - cmd->error_string = "can't write"; - return error("unable to write %s", lock_name); - } - if (verify_old_ref(name, old_hex) < 0) { - unlink(lock_name); - cmd->error_string = "raced"; - return error("%s changed during push", name); - } if (run_update_hook(name, old_hex, new_hex)) { - unlink(lock_name); cmd->error_string = "hook declined"; return error("hook declined to update %s", name); }