Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
5ebe18b7
Commit
5ebe18b7
authored
May 08, 2014
by
Russell Belfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2332 from libgit2/peff/iconv
iconv debugging aids
parents
ed476c23
56ec2256
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
1 deletions
+49
-1
CMakeLists.txt
+1
-1
examples/.gitignore
+1
-0
examples/Makefile
+1
-0
examples/for-each-ref.c
+46
-0
No files found.
CMakeLists.txt
View file @
5ebe18b7
...
...
@@ -207,7 +207,7 @@ ENDIF()
# Optional external dependency: iconv
IF
(
USE_ICONV
)
FIND_PACKAGE
(
I
CONV
)
FIND_PACKAGE
(
I
conv
)
ENDIF
()
IF
(
ICONV_FOUND
)
ADD_DEFINITIONS
(
-DGIT_USE_ICONV
)
...
...
examples/.gitignore
View file @
5ebe18b7
...
...
@@ -9,4 +9,5 @@ log
rev-parse
status
tag
for-each-ref
*.dSYM
examples/Makefile
View file @
5ebe18b7
...
...
@@ -4,6 +4,7 @@ CC = gcc
CFLAGS
=
-g
-I
../include
-I
../src
-Wall
-Wextra
-Wmissing-prototypes
-Wno-missing-field-initializers
LFLAGS
=
-L
../build
-lgit2
-lz
APPS
=
general showindex diff rev-list cat-file status log rev-parse init blame tag
APPS
+=
for
-each-ref
all
:
$(APPS)
...
...
examples/for-each-ref.c
0 → 100644
View file @
5ebe18b7
#include <git2.h>
#include <stdio.h>
#include "common.h"
static
int
show_ref
(
git_reference
*
ref
,
void
*
data
)
{
git_repository
*
repo
=
data
;
git_reference
*
resolved
=
NULL
;
char
hex
[
GIT_OID_HEXSZ
+
1
];
const
git_oid
*
oid
;
git_object
*
obj
;
if
(
git_reference_type
(
ref
)
==
GIT_REF_SYMBOLIC
)
check_lg2
(
git_reference_resolve
(
&
resolved
,
ref
),
"Unable to resolve symbolic reference"
,
git_reference_name
(
ref
));
oid
=
git_reference_target
(
resolved
?
resolved
:
ref
);
git_oid_fmt
(
hex
,
oid
);
hex
[
GIT_OID_HEXSZ
]
=
0
;
check_lg2
(
git_object_lookup
(
&
obj
,
repo
,
oid
,
GIT_OBJ_ANY
),
"Unable to lookup object"
,
hex
);
printf
(
"%s %-6s
\t
%s
\n
"
,
hex
,
git_object_type2string
(
git_object_type
(
obj
)),
git_reference_name
(
ref
));
if
(
resolved
)
git_reference_free
(
resolved
);
return
0
;
}
int
main
(
int
argc
,
char
**
argv
)
{
git_repository
*
repo
;
if
(
argc
!=
1
||
argv
[
1
]
/* silence -Wunused-parameter */
)
fatal
(
"Sorry, no for-each-ref options supported yet"
,
NULL
);
check_lg2
(
git_repository_open
(
&
repo
,
"."
),
"Could not open repository"
,
NULL
);
check_lg2
(
git_reference_foreach
(
repo
,
show_ref
,
repo
),
"Could not iterate over references"
,
NULL
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment