git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Rewrite branch in C and make it a builtin.

From
Shawn Pearce <spearce@spearce.org>
Date
Sep 2, 2006, 01:08 UTC
Message-ID
<20060902010806.GA24234@spearce.org>
In-Reply-To
<1156562127979-git-send-email-krh@redhat.com>
Kristian  H??gsberg <krh@redhat.com> wrote:
> A more or less straight port to C of the shell script version.
[snip]
> +static void create_reflog(struct ref_lock *lock)

I'm attaching a patch to the reflog code which introduces a new force_log option. You can use set this after you lock the ref but before writing it, provided that the user supplied -l on the command line.

This completely replaces the create_reflog function with common code.

I apologize for taking so long to get around to this but I've been busy with other stuff lately. :-)

-- 8> -- Add force_log flag to ref_lock to create logs when necessary.

Callers of lock_ref_sha1 or lock_any_ref_for_update may now set lck->force_log = 1 if they want to create the associated reflog during write_ref_sha1 if the log is missing.

If set this will override a false setting of the configuration parameter core.logAllRefUpdates and create a missing log, at which point future updates to the same ref would be logged as the log is present.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 refs.c |    2 +-
 refs.h |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/refs.c b/refs.c
index aab14fc..b29e2f4 100644
--- a/refs.c
+++ b/refs.c
@@ -361,7 +361,7 @@ static int log_ref_write(struct ref_lock
 	char *logrec;
 	const char *committer;
 
-	if (log_all_ref_updates) {
+	if (log_all_ref_updates || lock->force_log) {
 		if (safe_create_leading_directories(lock->log_file) < 0)
 			return error("unable to create directory for %s",
 				lock->log_file);
diff --git a/refs.h b/refs.h
index 553155c..d4798c9 100644
--- a/refs.h
+++ b/refs.h
@@ -7,7 +7,8 @@ struct ref_lock {
 	struct lock_file *lk;
 	unsigned char old_sha1[20];
 	int lock_fd;
-	int force_write;
+	int force_write; /* force creating ref if not present */
+	int force_log;   /* force creating log if not present */
 };
 
 /*
-- 
1.4.2.ga2654


-- 
VGER BF report: U 0.5
Previous: Kristian HøgsbergNext: Kristian Høgsberg
Message 2 of 3 in “Rewrite branch in C and make it a builtin.”
  1. Rewrite branch in C and make it a builtin.Kristian Høgsberg, Aug 26, 2006
  2. Shawn PearceSep 2, 2006
  3. Kristian HøgsbergSep 2, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.