Skip to content

Commit bc9c024

Browse files
committed
Merge branch 'maint'
* maint: GIT 1.6.0.4 Update RPM spec for the new location of git-cvsserver. push: fix local refs update if already up-to-date do not force write of packed refs Conflicts: builtin-revert.c
2 parents 5fe9cd0 + 7c181d6 commit bc9c024

File tree

5 files changed

+55
-23
lines changed

5 files changed

+55
-23
lines changed

Documentation/RelNotes-1.6.0.4.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Fixes since v1.6.0.3
1616
* 'git push --mirror' tried and failed to push the stash; there is no
1717
point in sending it to begin with.
1818

19+
* 'git push' did not update the remote tracking reference if the corresponding
20+
ref on the remote end happened to be already up to date.
21+
1922
* 'git pull $there $branch:$current_branch' did not work when you were on
2023
a branch yet to be born.
2124

@@ -29,12 +32,8 @@ Fixes since v1.6.0.3
2932

3033
* 'git svn' used deprecated 'git-foo' form of subcommand invocaition.
3134

35+
* 'git update-ref -d' to remove a reference did not honor --no-deref option.
36+
3237
* Plugged small memleaks here and there.
3338

3439
* Also contains many documentation updates.
35-
36-
--
37-
exec >/var/tmp/1
38-
O=v1.6.0.3-34-gf6276b7
39-
echo O=$(git describe maint)
40-
git shortlog --no-merges $O..maint

builtin-send-pack.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref)
230230
{
231231
struct refspec rs;
232232

233-
if (ref->status != REF_STATUS_OK)
233+
if (ref->status != REF_STATUS_OK && ref->status != REF_STATUS_UPTODATE)
234234
return;
235235

236236
rs.src = ref->name;
@@ -435,24 +435,19 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
435435
*/
436436
new_refs = 0;
437437
for (ref = remote_refs; ref; ref = ref->next) {
438-
const unsigned char *new_sha1;
439-
440-
if (!ref->peer_ref) {
441-
if (!args.send_mirror)
442-
continue;
443-
new_sha1 = null_sha1;
444-
}
445-
else
446-
new_sha1 = ref->peer_ref->new_sha1;
447438

439+
if (ref->peer_ref)
440+
hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
441+
else if (!args.send_mirror)
442+
continue;
448443

449-
ref->deletion = is_null_sha1(new_sha1);
444+
ref->deletion = is_null_sha1(ref->new_sha1);
450445
if (ref->deletion && !allow_deleting_refs) {
451446
ref->status = REF_STATUS_REJECT_NODELETE;
452447
continue;
453448
}
454449
if (!ref->deletion &&
455-
!hashcmp(ref->old_sha1, new_sha1)) {
450+
!hashcmp(ref->old_sha1, ref->new_sha1)) {
456451
ref->status = REF_STATUS_UPTODATE;
457452
continue;
458453
}
@@ -480,14 +475,13 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
480475
!ref->deletion &&
481476
!is_null_sha1(ref->old_sha1) &&
482477
(!has_sha1_file(ref->old_sha1)
483-
|| !ref_newer(new_sha1, ref->old_sha1));
478+
|| !ref_newer(ref->new_sha1, ref->old_sha1));
484479

485480
if (ref->nonfastforward && !ref->force && !args.force_update) {
486481
ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
487482
continue;
488483
}
489484

490-
hashcpy(ref->new_sha1, new_sha1);
491485
if (!ref->deletion)
492486
new_refs++;
493487

refs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,10 +795,10 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
795795
char *ref_file;
796796
const char *orig_ref = ref;
797797
struct ref_lock *lock;
798-
struct stat st;
799798
int last_errno = 0;
800799
int type, lflags;
801800
int mustexist = (old_sha1 && !is_null_sha1(old_sha1));
801+
int missing = 0;
802802

803803
lock = xcalloc(1, sizeof(struct ref_lock));
804804
lock->lock_fd = -1;
@@ -826,12 +826,13 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
826826
orig_ref, strerror(errno));
827827
goto error_return;
828828
}
829+
missing = is_null_sha1(lock->old_sha1);
829830
/* When the ref did not exist and we are creating it,
830831
* make sure there is no existing ref that is packed
831832
* whose name begins with our refname, nor a ref whose
832833
* name is a proper prefix of our refname.
833834
*/
834-
if (is_null_sha1(lock->old_sha1) &&
835+
if (missing &&
835836
!is_refname_available(ref, NULL, get_packed_refs(), 0))
836837
goto error_return;
837838

@@ -845,7 +846,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
845846
lock->ref_name = xstrdup(ref);
846847
lock->orig_ref_name = xstrdup(orig_ref);
847848
ref_file = git_path("%s", ref);
848-
if (lstat(ref_file, &st) && errno == ENOENT)
849+
if (missing)
849850
lock->force_write = 1;
850851
if ((flags & REF_NODEREF) && (type & REF_ISSYMREF))
851852
lock->force_write = 1;

t/t3210-pack-refs.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ test_expect_success \
9696
git branch -d n/o/p &&
9797
git branch n'
9898

99+
test_expect_success \
100+
'see if up-to-date packed refs are preserved' \
101+
'git branch q &&
102+
git pack-refs --all --prune &&
103+
git update-ref refs/heads/q refs/heads/q &&
104+
! test -f .git/refs/heads/q'
105+
99106
test_expect_success 'pack, prune and repack' '
100107
git tag foo &&
101108
git pack-refs --all --prune &&

t/t5516-fetch-push.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,37 @@ test_expect_success 'push updates local refs' '
437437
438438
'
439439

440+
test_expect_success 'push updates up-to-date local refs' '
441+
442+
rm -rf parent child &&
443+
mkdir parent &&
444+
(cd parent && git init &&
445+
echo one >foo && git add foo && git commit -m one) &&
446+
git clone parent child1 &&
447+
git clone parent child2 &&
448+
(cd child1 &&
449+
echo two >foo && git commit -a -m two &&
450+
git push) &&
451+
(cd child2 &&
452+
git pull ../child1 master &&
453+
git push &&
454+
test $(git rev-parse master) = $(git rev-parse remotes/origin/master))
455+
456+
'
457+
458+
test_expect_success 'push preserves up-to-date packed refs' '
459+
460+
rm -rf parent child &&
461+
mkdir parent &&
462+
(cd parent && git init &&
463+
echo one >foo && git add foo && git commit -m one) &&
464+
git clone parent child &&
465+
(cd child &&
466+
git push &&
467+
! test -f .git/refs/remotes/origin/master)
468+
469+
'
470+
440471
test_expect_success 'push does not update local refs on failure' '
441472
442473
rm -rf parent child &&

0 commit comments

Comments
 (0)