mirror of
https://github.com/git/git.git
synced 2024-11-18 17:13:55 +01:00
Merge branch 'maint'
* maint: rebase -i: do not fail when there is no commit to cherry-pick test-lib: fix color reset in say_color() fix pread()'s short read in index-pack Conflicts: csum-file.c
This commit is contained in:
commit
e782e12f89
18
csum-file.c
18
csum-file.c
@ -11,7 +11,7 @@
|
||||
#include "progress.h"
|
||||
#include "csum-file.h"
|
||||
|
||||
static void sha1flush(struct sha1file *f, void *buf, unsigned int count)
|
||||
static void flush(struct sha1file *f, void * buf, unsigned int count)
|
||||
{
|
||||
for (;;) {
|
||||
int ret = xwrite(f->fd, buf, count);
|
||||
@ -30,22 +30,28 @@ static void sha1flush(struct sha1file *f, void *buf, unsigned int count)
|
||||
}
|
||||
}
|
||||
|
||||
int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
|
||||
void sha1flush(struct sha1file *f)
|
||||
{
|
||||
int fd;
|
||||
unsigned offset = f->offset;
|
||||
|
||||
if (offset) {
|
||||
git_SHA1_Update(&f->ctx, f->buffer, offset);
|
||||
sha1flush(f, f->buffer, offset);
|
||||
flush(f, f->buffer, offset);
|
||||
f->offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
|
||||
{
|
||||
int fd;
|
||||
|
||||
sha1flush(f);
|
||||
git_SHA1_Final(f->buffer, &f->ctx);
|
||||
if (result)
|
||||
hashcpy(result, f->buffer);
|
||||
if (flags & (CSUM_CLOSE | CSUM_FSYNC)) {
|
||||
/* write checksum and close fd */
|
||||
sha1flush(f, f->buffer, 20);
|
||||
flush(f, f->buffer, 20);
|
||||
if (flags & CSUM_FSYNC)
|
||||
fsync_or_die(f->fd, f->name);
|
||||
if (close(f->fd))
|
||||
@ -83,7 +89,7 @@ int sha1write(struct sha1file *f, void *buf, unsigned int count)
|
||||
left -= nr;
|
||||
if (!left) {
|
||||
git_SHA1_Update(&f->ctx, data, offset);
|
||||
sha1flush(f, data, offset);
|
||||
flush(f, data, offset);
|
||||
offset = 0;
|
||||
}
|
||||
f->offset = offset;
|
||||
|
@ -24,6 +24,7 @@ extern struct sha1file *sha1fd(int fd, const char *name);
|
||||
extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
|
||||
extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
|
||||
extern int sha1write(struct sha1file *, void *, unsigned int);
|
||||
extern void sha1flush(struct sha1file *f);
|
||||
extern void crc32_begin(struct sha1file *);
|
||||
extern uint32_t crc32_end(struct sha1file *);
|
||||
|
||||
|
@ -277,7 +277,7 @@ do_next () {
|
||||
"$DOTEST"/amend || exit
|
||||
read command sha1 rest < "$TODO"
|
||||
case "$command" in
|
||||
'#'*|'')
|
||||
'#'*|''|noop)
|
||||
mark_action_done
|
||||
;;
|
||||
pick|p)
|
||||
@ -584,6 +584,7 @@ first and then run 'git rebase --continue' again."
|
||||
--abbrev=7 --reverse --left-right --cherry-pick \
|
||||
$UPSTREAM...$HEAD | \
|
||||
sed -n "s/^>/pick /p" > "$TODO"
|
||||
test -s "$TODO" || echo noop >> "$TODO"
|
||||
cat >> "$TODO" << EOF
|
||||
|
||||
# Rebase $SHORTUPSTREAM..$SHORTHEAD onto $SHORTONTO
|
||||
|
@ -707,6 +707,7 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,
|
||||
obj[1].idx.offset = obj[0].idx.offset + n;
|
||||
obj[1].idx.offset += write_compressed(f, buf, size);
|
||||
obj[0].idx.crc32 = crc32_end(f);
|
||||
sha1flush(f);
|
||||
hashcpy(obj->idx.sha1, sha1);
|
||||
return obj;
|
||||
}
|
||||
|
@ -419,4 +419,15 @@ test_expect_success 'rebase with a file named HEAD in worktree' '
|
||||
|
||||
'
|
||||
|
||||
test_expect_success 'do "noop" when there is nothing to cherry-pick' '
|
||||
|
||||
git checkout -b branch4 HEAD &&
|
||||
GIT_EDITOR=: git commit --amend \
|
||||
--author="Somebody else <somebody@else.com>"
|
||||
test $(git rev-parse branch3) != $(git rev-parse branch4) &&
|
||||
git rebase -i branch3 &&
|
||||
test $(git rev-parse branch3) = $(git rev-parse branch4)
|
||||
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -112,8 +112,9 @@ if test -n "$color"; then
|
||||
*) test -n "$quiet" && return;;
|
||||
esac
|
||||
shift
|
||||
echo "* $*"
|
||||
printf "* $*"
|
||||
tput sgr0
|
||||
echo
|
||||
)
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user