upload-pack: rename `enum` to reflect the operation
While 3145ea957d (upload-pack: introduce fetch server command, 2018-03-15) added support for the `fetch` command, from the server's point of view it is an upload, and hence the `enum` should really be called `upload_state` instead of `fetch_state`. Likewise, rename its values. This also helps unconfuse CodeQL which would otherwise be at sixes or sevens about having _two_ non-local definitions of the same `enum` with the same values. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
May 15, 2025 at 13:11 UTC
bf0468e2ba64ac358a61cb01a675b7c5919d64fd
1 file changed
+17
-17
upload-pack.c
+17
-17
@@ -1780,16 +1780,16 @@ static void send_shallow_info(struct upload_pack_data *data)
1780
packet_delim(1);
1781
}
1782
1783
-enum fetch_state {
1784
- FETCH_PROCESS_ARGS = 0,
1785
- FETCH_SEND_ACKS,
1786
- FETCH_SEND_PACK,
1787
- FETCH_DONE,
1783
+enum upload_state {
1784
+ UPLOAD_PROCESS_ARGS = 0,
1785
+ UPLOAD_SEND_ACKS,
1786
+ UPLOAD_SEND_PACK,
1787
+ UPLOAD_DONE,
1788
};
1789
1790
int upload_pack_v2(struct repository *r, struct packet_reader *request)
1791
{
1792
- enum fetch_state state = FETCH_PROCESS_ARGS;
1792
+ enum upload_state state = UPLOAD_PROCESS_ARGS;
1793
struct upload_pack_data data;
1794
1795
clear_object_flags(the_repository, ALL_FLAGS);
@@ -1798,9 +1798,9 @@ int upload_pack_v2(struct repository *r, struct packet_reader *request)
1798
data.use_sideband = LARGE_PACKET_MAX;
1799
get_upload_pack_config(r, &data);
1800
1801
- while (state != FETCH_DONE) {
1801
+ while (state != UPLOAD_DONE) {
1802
switch (state) {
1803
- case FETCH_PROCESS_ARGS:
1803
+ case UPLOAD_PROCESS_ARGS:
1804
process_args(request, &data);
1805
1806
if (!data.want_obj.nr && !data.wait_for_done) {
@@ -1811,27 +1811,27 @@ int upload_pack_v2(struct repository *r, struct packet_reader *request)
1811
* to just send 'have's without 'want's); guess
1812
* they didn't want anything.
1813
*/
1814
- state = FETCH_DONE;
1814
+ state = UPLOAD_DONE;
1815
} else if (data.seen_haves) {
1816
/*
1817
* Request had 'have' lines, so lets ACK them.
1818
*/
1819
- state = FETCH_SEND_ACKS;
1819
+ state = UPLOAD_SEND_ACKS;
1820
} else {
1821
/*
1822
* Request had 'want's but no 'have's so we can
1823
* immediately go to construct and send a pack.
1824
*/
1825
- state = FETCH_SEND_PACK;
1825
+ state = UPLOAD_SEND_PACK;
1826
}
1827
break;
1828
- case FETCH_SEND_ACKS:
1828
+ case UPLOAD_SEND_ACKS:
1829
if (process_haves_and_send_acks(&data))
1830
- state = FETCH_SEND_PACK;
1830
+ state = UPLOAD_SEND_PACK;
1831
else
1832
- state = FETCH_DONE;
1832
+ state = UPLOAD_DONE;
1833
break;
1834
- case FETCH_SEND_PACK:
1834
+ case UPLOAD_SEND_PACK:
1835
send_wanted_ref_info(&data);
1836
send_shallow_info(&data);
1837
@@ -1841,9 +1841,9 @@ int upload_pack_v2(struct repository *r, struct packet_reader *request)
1841
packet_writer_write(&data.writer, "packfile\n");
1842
create_pack_file(&data, NULL);
1843
}
1844
- state = FETCH_DONE;
1844
+ state = UPLOAD_DONE;
1845
break;
1846
- case FETCH_DONE:
1846
+ case UPLOAD_DONE:
1847
continue;
1848
}
1849
}