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

Re: [PATCH 2/2] interpret-trailers: add option for in-place editing

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jan 11, 2016, 16:33 UTC
Message-ID
<vpqziwc3wjv.fsf@anie.imag.fr>
In-Reply-To
<1452519213-1819-3-git-send-email-tklauser@distanz.ch>
Tobias Klauser <tklauser@distanz.ch> writes:
Show 6 quoted lines
> @@ -843,7 +844,9 @@ static void free_all(struct trailer_item **first)
>  	}
>  }
>  
> -void process_trailers(const char *file, int trim_empty, struct string_list *trailers)
> +static struct tempfile trailers_tempfile;

Does this need to be a static global? I'd rather have this be a local variable of process_trailers.

> +			die_errno(_("could not fdopen tempfile"));

I think you should spell it "could not open temporary file" to be more user-friendly.

Show 8 quoted lines
> @@ -872,5 +900,10 @@ void process_trailers(const char *file, int trim_empty, struct string_list *trai
>  	/* Print the lines after the trailers as is */
>  	print_lines(outfile, lines, trailer_end, INT_MAX);
>  
> +	if (in_place) {
> +		if (rename_tempfile(&trailers_tempfile, file))
> +			die_errno(_("could not rename tempfile"));
> +	}

When this happens, I think you also want to try removing the temporary file. Not sure, though: it may be nice to leave the tempfile for the user to debug. What do we do in other places of the code?

It may help the user to get "could not rename temporary file %s to %s" in case this happens.

On overall, the split makes the series much more pleasant to review, and other than these details, this sounds good to me. Thanks!

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Tobias KlauserNext: Tobias Klauser
Message 4 of 6 in “Add in-place editing support to git interpret-trailers”
  1. 0/2 Add in-place editing support to git interpret-trailersTobias Klauser, Jan 11, 2016
  2. 1/2 trailer: use fprintf instead of printfTobias Klauser, Jan 11, 2016
  3. 2/2 interpret-trailers: add option for in-place editingTobias Klauser, Jan 11, 2016
  4. Matthieu MoyJan 11, 2016
  5. Tobias KlauserJan 11, 2016
  6. Matthieu MoyJan 11, 2016

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.