mirror of
https://github.com/git/git.git
synced 2026-03-13 18:33:25 +01:00
Merge branch 'master' into next
* master: write_in_full: size_t is unsigned. create_symref: check error return from open(). vc-git.el: Take into account the destination name in vc-checkout. git-merge: leave sensible reflog message when used as the first level UI. Make sure we do not write bogus reflog entries.
This commit is contained in:
@@ -53,10 +53,6 @@
|
||||
(let ((name (file-relative-name file)))
|
||||
(eq 0 (apply #'call-process "git" nil (get-buffer "*Messages") nil (append args (list name))))))
|
||||
|
||||
(defun vc-git--run-command-out (output &rest args)
|
||||
"Run a git command, output to output."
|
||||
(eq 0 (apply #'call-process "git" nil output nil (append args))))
|
||||
|
||||
(defun vc-git-registered (file)
|
||||
"Check whether FILE is registered with git."
|
||||
(with-temp-buffer
|
||||
@@ -125,26 +121,14 @@
|
||||
|
||||
(defun vc-git-checkout (file &optional editable rev destfile)
|
||||
(if destfile
|
||||
(let ((mybuff (get-buffer-create "vc-git-checkout-tmp")))
|
||||
(let ((rv
|
||||
(vc-git--run-command-out
|
||||
mybuff "cat-file" "blob"
|
||||
(concat (or rev "HEAD")
|
||||
":"
|
||||
(let ((output (vc-git--run-command-string
|
||||
(file-relative-name file)
|
||||
"ls-files" "--full-name")))
|
||||
(string-match "\\(.*\\)" output)
|
||||
(match-string 1 output))
|
||||
)))
|
||||
)
|
||||
(if rv
|
||||
(save-current-buffer
|
||||
(set-buffer mybuff)
|
||||
(set-visited-file-name destfile t)
|
||||
(save-buffer)
|
||||
)
|
||||
rv)))
|
||||
(let ((fullname (substring
|
||||
(vc-git--run-command-string file "ls-files" "-z" "--full-name" "--")
|
||||
0 -1))
|
||||
(coding-system-for-read 'no-conversion)
|
||||
(coding-system-for-write 'no-conversion))
|
||||
(with-temp-file destfile
|
||||
(eq 0 (call-process "git" nil t nil "cat-file" "blob"
|
||||
(concat (or rev "HEAD") ":" fullname)))))
|
||||
(vc-git--run-command file "checkout" (or rev "HEAD"))))
|
||||
|
||||
(defun vc-git-annotate-command (file buf &optional rev)
|
||||
|
||||
@@ -7,7 +7,6 @@ USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commi
|
||||
|
||||
SUBDIRECTORY_OK=Yes
|
||||
. git-sh-setup
|
||||
set_reflog_action "merge $*"
|
||||
require_work_tree
|
||||
cd_to_toplevel
|
||||
|
||||
@@ -262,6 +261,7 @@ head=$(git-rev-parse --verify "$head_arg"^0) || usage
|
||||
|
||||
# All the rest are remote heads
|
||||
test "$#" = 0 && usage ;# we need at least one remote head.
|
||||
set_reflog_action "merge $*"
|
||||
|
||||
remoteheads=
|
||||
for remote
|
||||
|
||||
45
refs.c
45
refs.c
@@ -331,7 +331,11 @@ int create_symref(const char *ref_target, const char *refs_heads_master)
|
||||
return -1;
|
||||
}
|
||||
lockpath = mkpath("%s.lock", git_HEAD);
|
||||
fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);
|
||||
fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);
|
||||
if (fd < 0) {
|
||||
error("Unable to open %s for writing", lockpath);
|
||||
return -5;
|
||||
}
|
||||
written = write_in_full(fd, ref, len);
|
||||
close(fd);
|
||||
if (written != len) {
|
||||
@@ -925,6 +929,7 @@ static int log_ref_write(struct ref_lock *lock,
|
||||
{
|
||||
int logfd, written, oflags = O_APPEND | O_WRONLY;
|
||||
unsigned maxlen, len;
|
||||
int msglen;
|
||||
char *logrec;
|
||||
const char *committer;
|
||||
|
||||
@@ -958,24 +963,30 @@ static int log_ref_write(struct ref_lock *lock,
|
||||
lock->log_file, strerror(errno));
|
||||
}
|
||||
|
||||
committer = git_committer_info(-1);
|
||||
msglen = 0;
|
||||
if (msg) {
|
||||
maxlen = strlen(committer) + strlen(msg) + 2*40 + 5;
|
||||
logrec = xmalloc(maxlen);
|
||||
len = snprintf(logrec, maxlen, "%s %s %s\t%s\n",
|
||||
sha1_to_hex(lock->old_sha1),
|
||||
sha1_to_hex(sha1),
|
||||
committer,
|
||||
msg);
|
||||
}
|
||||
else {
|
||||
maxlen = strlen(committer) + 2*40 + 4;
|
||||
logrec = xmalloc(maxlen);
|
||||
len = snprintf(logrec, maxlen, "%s %s %s\n",
|
||||
sha1_to_hex(lock->old_sha1),
|
||||
sha1_to_hex(sha1),
|
||||
committer);
|
||||
/* clean up the message and make sure it is a single line */
|
||||
for ( ; *msg; msg++)
|
||||
if (!isspace(*msg))
|
||||
break;
|
||||
if (*msg) {
|
||||
const char *ep = strchr(msg, '\n');
|
||||
if (ep)
|
||||
msglen = ep - msg;
|
||||
else
|
||||
msglen = strlen(msg);
|
||||
}
|
||||
}
|
||||
|
||||
committer = git_committer_info(-1);
|
||||
maxlen = strlen(committer) + msglen + 100;
|
||||
logrec = xmalloc(maxlen);
|
||||
len = sprintf(logrec, "%s %s %s\n",
|
||||
sha1_to_hex(lock->old_sha1),
|
||||
sha1_to_hex(sha1),
|
||||
committer);
|
||||
if (msglen)
|
||||
len += sprintf(logrec + len - 1, "\t%.*s\n", msglen, msg) - 1;
|
||||
written = len <= maxlen ? write_in_full(logfd, logrec, len) : -1;
|
||||
free(logrec);
|
||||
close(logfd);
|
||||
|
||||
@@ -23,7 +23,7 @@ int write_in_full(int fd, const void *buf, size_t count)
|
||||
ssize_t total = 0;
|
||||
|
||||
while (count > 0) {
|
||||
size_t written = xwrite(fd, p, count);
|
||||
ssize_t written = xwrite(fd, p, count);
|
||||
if (written < 0)
|
||||
return -1;
|
||||
if (!written) {
|
||||
|
||||
Reference in New Issue
Block a user